Friday, July 3, 2009

Use of Dataview Find / FindRow OR DataTable Filtering


Some time people will get into confusion of usage and which object need to be used .Most of the time when we are dealing with a set of Data we have to filter the data based on certain criteria.Normally we all are dealing with two objects called DataView and DataTable. Let how these object can support filtering option.

1.Using DataTable

DataRow[] rows = dataTable.Select("Age > '25'", "Eid DESC")

Here you have a datatable in which you are applying filter condition as well as sorting order.

2.Using DataView

dataView.Sort = "ID";
DataRowView[] rows = dataView.FindRows("2500");

Here the limitation is you have to sort based on coloumn then filter based on that coloumn

3.Using DataView with filter Property
Dataset1.Tables[0].DefaultView.RowFilter = "Age > '25'";

Cheers
Shyju Mohan

No comments:

Post a Comment