Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

code to populate a combobox with values from an xml file

Tags:

c#

xml

combobox

How to populate combobox with values from an xml file.

like image 277
anasooya Avatar asked May 03 '11 04:05

anasooya


1 Answers

Using XmlDocument class you can loop thru the nodes of xml file and then just go on adding items to dropdownlist. Sample code:

 XmlDocument doc = new XmlDocument();
    doc.Load(Server.MapPath("regis.xml"));
    XmlNodeList colorList = doc.SelectNodes("Information/Comments/Name");
    foreach (XmlNode Name in colorList)
    {
      DropDownList1.Items.Add(Name.InnerText);
    }

Ref : http://r4r.co.in/asp.net/01/tutorial/asp.net/How%20to%20populate%20combobox%20from%20xml%20file%20using%20c-Sharp%20in%20asp.net.shtml

like image 199
pramodtech Avatar answered Nov 14 '22 22:11

pramodtech