Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dataview Behavior

Status
Not open for further replies.

wittybanter

Programmer
Oct 25, 2005
3
CA
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.
 
Code:
view[!].Table[/!]
You are going back to the DataTable and viewing the rows from there, so as expected they will not be sorted.

Why can't you sort these records in the database?


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
It's an Oracle stored proc that I have no access to.
BTW, you hit it on the head for me.

view[0][1].ToString ());

does what I am expecting it to do. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top