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?
Printable View
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?
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>";
Sort is a property, not a method, which is why you're assigning a value to it rather than calling it.Quote:
Originally Posted by Harsh Gupta
If you're not using a DataTable then arrays and the generic List class also have Sort members, and these ones are methods. ;)
My bad. Yes it is a property. Can't even say that was a typo!!! :cry:
Get your XmlNodeList, put it in a List<yourtype> and then sort it.