How can we filter in Dataset ? How can we do the sorting in Dataset ?
Microsoft make it easy and provide the Dataview. To use of Dataview object, which is specifically designed for sorting and filtering rows and can be used as a Datasource in its own right. So we can bind a Datagrid column in customized "View".
We can set an instance of Dataview object from the default view property of our DataTable. Than we can set its sort & row filter property.
DataView Dv = dst.Tables[0].DefaultView; //Dst is Dataset where collection of emplyee present
Dv.RowFilter = "Username like 'bob%'"; // Filter the Username start with Bob
Dv.Sort = "DateJoined DESC"; // desc order by datejoined
How to Filter Datatable? How to filter Datatable?
it is same like above, instead of dataset use datatable.
DataView Dv = dat.DefaultView; //Dst is Dataset where collection of emplyee present
Dv.RowFilter = "Username like 'bob%'"; // Filter the Username start with Bob
Dv.Sort = "DateJoined DESC"; // desc order by datjoined
No comments:
Post a Comment