wittybanter
Programmer
I have a large dataset that I need to sort out (can't do it on the DB side).
DataView view = new DataView(ds.Tables[0]);
view.Sort = "PA_FIRST_NAME ASC";
This works when I iterate through the data using:
foreach (DataRowView drv in view)
{Response.Write(drv["PA_FIRST_NAME"].ToString() + "<BR/>");}
This will give me the 10 records that I have in the sorted order. However, if I just try and spit out the 5th row, it is NOT sorted. Can anyone tell me why this is? For example, If I use:
Response.Write (view.Table.Rows[0][1].ToString ());
It will spit out the first record from the dataview as though I did not sort it at all (since I am doing a sort by Firstname, it should be "Alex" that comes up, but instead the original "Peter" does.
DataView view = new DataView(ds.Tables[0]);
view.Sort = "PA_FIRST_NAME ASC";
This works when I iterate through the data using:
foreach (DataRowView drv in view)
{Response.Write(drv["PA_FIRST_NAME"].ToString() + "<BR/>");}
This will give me the 10 records that I have in the sorted order. However, if I just try and spit out the 5th row, it is NOT sorted. Can anyone tell me why this is? For example, If I use:
Response.Write (view.Table.Rows[0][1].ToString ());
It will spit out the first record from the dataview as though I did not sort it at all (since I am doing a sort by Firstname, it should be "Alex" that comes up, but instead the original "Peter" does.