all groups > dotnet windows forms > june 2005 >
You're in the

dotnet windows forms

group:

Multiple Data Views to sort and filter data in a dataset?



Multiple Data Views to sort and filter data in a dataset? Troy
6/21/2005 7:11:06 PM
dotnet windows forms: I was under the impression that you could use data views to have multiple
sorts and filters on a dataset or data table. I want to bind two different
combo boxes to different data views for a single table. I set the row filter
for the first data view and bind the view to the combo box, I then set the
row filter for the second view and bind it to the second combo box. Both
combo boxes display the last row filter applied to the data set even though
they were bound to different views? I think I am missing something.

ToDV = addresses_DS.Tables["Customer_Address_MSTR"].DefaultView;
ToDV.RowFilter = "TypeID = 'To'";
ToDV.Sort = "NameID";

toName.DataBindings.Clear();
toName.DataSource = ToDV;
toName.DisplayMember = "NameID";
toName.ValueMember = "NameID";
toName.SelectedItem = null;

FromDV = addresses_DS.Tables["Customer_Address_MSTR"].DefaultView;
FromDV.RowFilter = "TypeID = 'From'";
FromDV.Sort = "NameID";

fromName.DataBindings.Clear();
fromName.DataSource = FromDV;
fromName.DisplayMember = "NameID";
fromName.ValueMember = "NameID";
fromName.SelectedItem = null;



--
Re: Multiple Data Views to sort and filter data in a dataset? Mark Broadbent
6/22/2005 12:00:00 AM
On both your ToDV and FromDV you are repointing your reference to a table.
You simply need to set the DataView's Table property to the relevant table.

e.g. this is a snippet of some of my code where i use a dataview to show a
user all changes they have made via datagrid1.

this.oleDbDataAdapter1.Fill(dataSet11);
this.dataGrid1.DataSource = dataSet11.Tables[0];
this.dataView1.Table = dataSet11.Tables[0];
this.dataView1.RowStateFilter =
System.Data.DataViewRowState.ModifiedOriginal;
this.dataGrid2.DataSource = dataView1;

br,

Mark.


[quoted text, click to view]

Re: Multiple Data Views to sort and filter data in a dataset? Troy
6/22/2005 5:59:03 PM
I get It, I was creating two pointers/references to the table default view,
not creating copies of the default view that would maintain their own
properties.

Adjusting the code to this, is what I really wanted to do and works perfect.
ToDV = new DataView();
ToDV.Table = addresses_DS.Tables["Customer_Address_MSTR"];

Thanks Mark,
--
T.Kitt


[quoted text, click to view]
AddThis Social Bookmark Button