2
Answers

How do i load a XML data to a Combobox?

Sniffer Bits

Sniffer Bits

11y
3.8k
1
hi friends,
I have search this on this net but most XML data they have used only with one attributes. My XML structure as follows
 
<Countries>
<Country>
<ISO>USA</ISO>
<Name>United States</Name>
</Country>
<Country>
<ISO>RUS</ISO>
<Name>Russian Federation</Name>
</Country>
<Country>
<ISO>PRC</ISO>
<Name>China</Name>
</Country>
</Countries>
 
How do I load above data to a combobox, have Display Member as Name and the Value Member as ISO?
Answers (2)
2
Dhirendra Misra

Dhirendra Misra

NA 982 11.8k 11y
Hello Sniffer,

You can make use of DataSet.
1. Create a new dataset.
2. Use the dataset to read the XML file
3. Bind the dataset to the drop down list.

Refer the following which has similar XML as you have.
http://www.itjungles.com/the-easiest-way-to-populate-drop-down-list-with-xml-in-c.html


above article is for web dropdown list but approach is going to same.

for combobox you can refer:
http://www.codeproject.com/Questions/551677/populatepluscomboplusboxplusinplusc-23
Accepted
0
Lakshmanan Sethu

Lakshmanan Sethu

NA 19.3k 2.4m 11y
Hi Sniffer, Happy Morning. You can use asp.net xmldatasource to load your xml and use this source for your combobox. Please refer the article http://www.c-sharpcorner.com/uploadfile/b19d5a/dropdownlist-data-binding-from-xml-file-in-Asp-Net/