DataGrid
-
How could I change the
data source
of adataGrid
in run time (Windows Forms)?datagrid.Update()
What I am trying to do is, to change the data source of the data grid with respect to CustomerID.. If customerID is changed, than the dataView will retrieve the data from DataSet table and then update the datagrid ,without changing data source , update data source with DataView But I couldnt find the method, please guide me to achieve. Is it possible ? Thanks , Bahadir Cambel -
How could I change the
data source
of adataGrid
in run time (Windows Forms)?datagrid.Update()
What I am trying to do is, to change the data source of the data grid with respect to CustomerID.. If customerID is changed, than the dataView will retrieve the data from DataSet table and then update the datagrid ,without changing data source , update data source with DataView But I couldnt find the method, please guide me to achieve. Is it possible ? Thanks , Bahadir CambelHi, Why to change the datasource? Instead that we can associate the Dataview to the datagrid. Filter the DataSet into Dataview using RowFilter and RowStateFilter properties of Dataview. Dataview.RowFilter = "customerID=xxxx"; Thanks SGS
-
Hi, Why to change the datasource? Instead that we can associate the Dataview to the datagrid. Filter the DataSet into Dataview using RowFilter and RowStateFilter properties of Dataview. Dataview.RowFilter = "customerID=xxxx"; Thanks SGS
thanks for the reply , but my problem is to update the datagrid. I can not update the dataGrid when I change the dataView. To be more specific I have a curreny manager which is holding the information about the customers named cm I have 2 dataTables dt_Orders and dt_Customers for orders and customers I inserted the update operation into ShowCurrentRecord which is called when CurrenyManager_PositionChanged event..
private void cm_PositionChanged(object sender, EventArgs e) { ShowCurrentRecord(); } private void ShowCurrentRecord() { string CustomerID=ds_Customers.Tables["dt_Customers"].Rows[cm.Position]["CustomerID"].ToString(); for(int i =0 ;i <RowCount ;i++) { //If the selected Customer has an Order(s) in dt_Orders, update the dataGrid if ( ds_Customers.Tables["dt_Orders"].Rows[i]["CustomerID"].ToString()==CustomerID ) {myDataView.RowFilter="CustomerID="+CustomerID;
It turned out to be , I can not set anything into RowFilter.. even if I tried dv.RowFilter="CustomerID"+CustomerID; dv.AllowEdit(); dv.BeginInit(); When I use Watch the find the value , although CustomerID has its value , watch always shows RowFilter as null string.. Does dataView can be edited in run-time ?
-
thanks for the reply , but my problem is to update the datagrid. I can not update the dataGrid when I change the dataView. To be more specific I have a curreny manager which is holding the information about the customers named cm I have 2 dataTables dt_Orders and dt_Customers for orders and customers I inserted the update operation into ShowCurrentRecord which is called when CurrenyManager_PositionChanged event..
private void cm_PositionChanged(object sender, EventArgs e) { ShowCurrentRecord(); } private void ShowCurrentRecord() { string CustomerID=ds_Customers.Tables["dt_Customers"].Rows[cm.Position]["CustomerID"].ToString(); for(int i =0 ;i <RowCount ;i++) { //If the selected Customer has an Order(s) in dt_Orders, update the dataGrid if ( ds_Customers.Tables["dt_Orders"].Rows[i]["CustomerID"].ToString()==CustomerID ) {myDataView.RowFilter="CustomerID="+CustomerID;
It turned out to be , I can not set anything into RowFilter.. even if I tried dv.RowFilter="CustomerID"+CustomerID; dv.AllowEdit(); dv.BeginInit(); When I use Watch the find the value , although CustomerID has its value , watch always shows RowFilter as null string.. Does dataView can be edited in run-time ?
Hahahah , the whole problem was
myDataView.RowFilter = "CustomerID= '"+CustomerID+"'";
: ) -
Hahahah , the whole problem was
myDataView.RowFilter = "CustomerID= '"+CustomerID+"'";
: )Ok. Guess your problem is solved now :)