binding individual columns of a datgrid to a dataset/datatable
-
hello all, could some one tell me how could i bind the individual columns, already created to a dataset or a datatable during runtime. thanks in advance.
Keshav Kamat :) India
-
hello all, could some one tell me how could i bind the individual columns, already created to a dataset or a datatable during runtime. thanks in advance.
Keshav Kamat :) India
could you give us an example of what you're trying to achieve? because binding different columns to different datasources doesn't make much sense to me. Might just be me though ;) Please clarify.
public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }
-
could you give us an example of what you're trying to achieve? because binding different columns to different datasources doesn't make much sense to me. Might just be me though ;) Please clarify.
public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }
ya sure. well here is my case. i have a database, which has several columns. I need to modify the contents of a single column. Looking at a different side, binding a single column to a separate data source doesnt make sense to me either. what I really want is to modify the contents of a cell of a column of a datagrid. Can i do it using a datatable or a dataset, coz it is much faster, than accessing a datagrid as Datagrid1.Rows[i].Cells[j]. m trying to modify a cell. how to do it, if i bind a datagrid to a datatable.
Keshav Kamat :) India
-
ya sure. well here is my case. i have a database, which has several columns. I need to modify the contents of a single column. Looking at a different side, binding a single column to a separate data source doesnt make sense to me either. what I really want is to modify the contents of a cell of a column of a datagrid. Can i do it using a datatable or a dataset, coz it is much faster, than accessing a datagrid as Datagrid1.Rows[i].Cells[j]. m trying to modify a cell. how to do it, if i bind a datagrid to a datatable.
Keshav Kamat :) India
-
You can edit individual cells in DataTables in the same way as you edit cells in a DataGridView. You can (or have to) use DataTable.Rows[i].Cells[j]...
public object BufferOverFlow { __get { return BufferOverFlow; } __set { BufferOverFlow = value; } }
well ok. as u said in the previous replies, when i try to bind a datagrid to a data table and try to access the cell or the row count of the data table, it says object reference not set. it comes null. here is how i try to bind a datagrid to a datatable. DataTable dt1=new DataTable("dt1"); dt1 = (DataTable)LoggerDatagrid.DataSource; please tell me, if I am making a mistake anywhere. thanks in advance.
Keshav Kamat :) India
-
well ok. as u said in the previous replies, when i try to bind a datagrid to a data table and try to access the cell or the row count of the data table, it says object reference not set. it comes null. here is how i try to bind a datagrid to a datatable. DataTable dt1=new DataTable("dt1"); dt1 = (DataTable)LoggerDatagrid.DataSource; please tell me, if I am making a mistake anywhere. thanks in advance.
Keshav Kamat :) India
-
well ok. as u said in the previous replies, when i try to bind a datagrid to a data table and try to access the cell or the row count of the data table, it says object reference not set. it comes null. here is how i try to bind a datagrid to a datatable. DataTable dt1=new DataTable("dt1"); dt1 = (DataTable)LoggerDatagrid.DataSource; please tell me, if I am making a mistake anywhere. thanks in advance.
Keshav Kamat :) India
You're doing it the wrong way around. It should be :
LoggerDatagrid.DataSource = dt1;
now your datagrid should be populated, and then you can start looking for cells to edit.
Visual Studio can't evaluate this, can you?
public object moo { __get { return moo; } __set { moo = value; } }