|
-
Dec 4th, 2008, 06:25 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] sorting drop down list
I am retrieving values from xml and put it to the drop down list control. But it's out of order, how can I sort them?
-
Dec 6th, 2008, 12:33 AM
#2
Re: sorting drop down list
Are you using DataSet/DataTable to read data from XML? If so, you can call the Sort() method of its DefaultView and set the order name.
E.g., Assuming you are using DataTable
C# Code:
//DataTable dt = reading data from xml dt.DefaultView.Sort = "<columnname> <ASC/DESC>";
-
Dec 6th, 2008, 06:15 AM
#3
Re: sorting drop down list
 Originally Posted by Harsh Gupta
you can call the Sort() method of its DefaultView
Sort is a property, not a method, which is why you're assigning a value to it rather than calling it.
If you're not using a DataTable then arrays and the generic List class also have Sort members, and these ones are methods.
-
Dec 6th, 2008, 07:12 AM
#4
Re: sorting drop down list
My bad. Yes it is a property. Can't even say that was a typo!!!
-
Dec 8th, 2008, 03:41 PM
#5
Re: sorting drop down list
Get your XmlNodeList, put it in a List<yourtype> and then sort it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|