M
mathieu
Hello, here's my problem..
I have a dataset composed of 5 or so datatable composed of the
following columns
Columns.AddRange(new DataColumn[]
{
new DataColumn("Id", System.Type.GetType("System.Int32")),
new DataColumn("Lib", System.Type.GetType("System.String")),
new DataColumn("ParentId", System.Type.GetType("System.Int32"))}
);
Each datatable is in a relation Parent-Child as follow:
Relations.Add(Tables[i-1].Columns["Id"],
Tables.Columns["ParentId"]);
Now, I want to filter tables on the row Id or Lib.
But if for example i find a lib (or id) corresponding in let's say
table 4, I must show the parent of that row till i'm back to the top.
To do so i created a hidden column called "Flag" and update it
manually when a search occur. I begin by searchin the last table and
set Flag=1 to all rows returned. Then goes to the level before and
search again. But this time my filter will be
"Sum(Child.Flag)>0 OR " + MyFilter
This way i get the rows in the current level that matches the search
criteria and also the ones that don't but have a child that does.
Now when i'm done i create a new dataview for each table like this
DataView dvSearch = new DataView(myTable);
dvSearch.RowFilter = "Flag=1";
After i bind the first table dataview (the search one)to a datagrid.
dataGrid1.DataSource = DataViewSearchOfFirstTable;
The problem is that the DataGrid show all the table rows and not only
the filtered one? what is wrong ? I'm not used to work with DataTable
and DataView Should i use instead a DataViewManager?
ps: For sure the Flag is correctly set to 1 on rows matching the
search criteria and the parent.
Thanks
Mathieu
I have a dataset composed of 5 or so datatable composed of the
following columns
Columns.AddRange(new DataColumn[]
{
new DataColumn("Id", System.Type.GetType("System.Int32")),
new DataColumn("Lib", System.Type.GetType("System.String")),
new DataColumn("ParentId", System.Type.GetType("System.Int32"))}
);
Each datatable is in a relation Parent-Child as follow:
Relations.Add(Tables[i-1].Columns["Id"],
Tables.Columns["ParentId"]);
Now, I want to filter tables on the row Id or Lib.
But if for example i find a lib (or id) corresponding in let's say
table 4, I must show the parent of that row till i'm back to the top.
To do so i created a hidden column called "Flag" and update it
manually when a search occur. I begin by searchin the last table and
set Flag=1 to all rows returned. Then goes to the level before and
search again. But this time my filter will be
"Sum(Child.Flag)>0 OR " + MyFilter
This way i get the rows in the current level that matches the search
criteria and also the ones that don't but have a child that does.
Now when i'm done i create a new dataview for each table like this
DataView dvSearch = new DataView(myTable);
dvSearch.RowFilter = "Flag=1";
After i bind the first table dataview (the search one)to a datagrid.
dataGrid1.DataSource = DataViewSearchOfFirstTable;
The problem is that the DataGrid show all the table rows and not only
the filtered one? what is wrong ? I'm not used to work with DataTable
and DataView Should i use instead a DataViewManager?
ps: For sure the Flag is correctly set to 1 on rows matching the
search criteria and the parent.
Thanks
Mathieu