I have used to select method to get the data from datatable.
For example
For example
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Group", typeof(int)));
dt.Columns.Add(new DataColumn("name", typeof(string)));
DataRow dr = dt.NewRow();
dr["Group"] = 1;
dr["name"] = "Apple";
dt.Rows.Add(dr);
dr["Group"] = 2;
dr["name"] = "Milk";
dt.Rows.Add(dr);
dr["Group"] = 1;
dr["name"] = "Orange";
dt.Rows.Add(dr);
dr["Group"] = 2;
dr["name"] = "Curd";
dt.Rows.Add(dr);
So the following order the data is in datatable
Group Name
=================
1 Apple
2 Milk
1 Orange
2 Curd
The following select statement to get the data.
DataRow[] dr1 = dt.Select("group in (1,2)");
But the items are fetching different order. like this
Group Name
====================
1 Apple
1 Orange
2 Milk
2 Curd
I need to fetching the actual order. Like this
Group Name
====================
1 Apple
2 Milk
1 Orange
2 Curd
I tried to use dataview rowfilter instead of datatable.select when it is working fine.
Here this,
DataView dv = dt.DefaultView;
dv.RowFilter = "group in (1,2)";
dt = dv.ToTable();