View Single Post
 
Old November 23rd, 2007, 08:08 AM
Hughesie78 Hughesie78 is offline
Authorized User
 
Join Date: Nov 2007
Location: , , Ireland.
Posts: 67
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Hughesie78
Default Sort XML in dropdownlist

Hi,
I have a dropdown list on an aspx form which is being populated by distinct values on an XML file.
Now I need to sort the data in alpbabetical order. Any ideas?

Here is my code for populating the dropdown list:

   if (!Page.IsPostBack)
            // load the xml.
        {
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("Banks.xml"));
            XmlDataDocument XMLDoc = new XmlDataDocument(ds);
            //for populating the ddl_Banks
            foreach (XmlNode XMLNodes in XMLDoc.SelectNodes("//bank[not(.=preceding::bank)]"))
            {

                ddl_Banks.Items.Add(
                    new ListItem(XMLNodes.ChildNodes[0].InnerText.ToString()));

            }
        }
__________________
Thank You