I have an XML file that contains multiple datagrid configuration scripts. The XML file is being read as a standard DataSet. What seems to be happening is that the last rowfilter is overwriting the current one even though a new instance of it was created.
pseudo code:
Filter the default view or the primary table of the DATASET
Create a new empty DATAVIEW object
set the new DATAVIEW object to the DefaultView with the filter.
set the new DATAVIEW as the config file of the datagrid.
Create a new filter for the DATASET.
Create a new empty DATAVIEW object (different name);
set the new DATAVIEW object to the Defaultview with the new filter
set the new DATAVIEW as the config file of the second datagrid.
bind the first datagrid.
end pseudo code
Well what happens is that the first datagrid seems to be using the second datagrids config DATAVIEW even though I created a new DATAVIEW object and set the first filtered Defaultview to that. Then gave that DATAVIEW as the first datagrids config DataView.
here is some of the code
//Set the datatable to filter based upon a value (grab the columns for this datagrid)
dsCol.Tables[1].DefaultView.RowFilter = "GridName='GridPrime'";
//Create a new object for DataView
DataView DRV1 = new DataView();
//Set the new object to the previously created dataview
DRV1 = dsCol.Tables[1].DefaultView;
//set the config file for the datagrid
myDataGrid1.DataCols = DRV1;
//get the data to be displayed
dsData.ReadXml(sPath + "DataDrill.xml");
//set the datasource fo the datagrid
myDataGrid1.DataSource = dsData.Tables[0];
//Create the new view
dsCol.Tables[1].DefaultView.RowFilter = "GridName='GridDetail'";
//New instance
DataView DRV2 = new DataView();
//set new instance to the view
DRV2 = dsCol2.Tables[1].DefaultView;
//set the new object as the config file of the second datagrid
myDataGrid2.DataCols = DRV2;
//The second datagrids datasoruce is the second table int he dataset
myDataGrid2.DataSource = dsData.Tables[1];
//DataBind the first datagrid
myDataGrid1.DataBind(); //It uses the what ever the last defaultview.rowfilter was set
So guys to you have any ideas? I have to use the XML files the way they are. So I can't use improvements to what data is actually put into the datasets.
The difference between genius and madness is success. And I haven't been too successful.