User Id :    Password :      New Member   Forgot Password  
Fill Combo Box from the XML
Description Fill Combo Box by fetching the data from XML.   No. of Views     5455
  Rating     0
Author Gaurav   Posted On     02 Sep 2012
Tags Windows Programming,XML,XML : General    

Sample Code   Download Code

This is very common article .We always come into situations in which we need to fetch values from xml and fill the combo box.In this article, I will show you how to fill the combo box by fetching the data from xml.

This is the below sample XML:


      <value>Press Release</value>
      <value>Content Update</value>

Now the c# code to fetch and bind the data with combo box:

private void Form1_Load(object sender, EventArgs e)
            XmlDocument doc = new XmlDocument(); 

          //Path of the XMl file
           // Read the node of the XML
            XmlNodeList RequestTypeNodes = doc.GetElementsByTagName("RequestTypeDetails");
         // Make a object of list type
           List RequestTypeMails = new List(); 

         // Read the XML child node and fill the List
           foreach (XmlNode node in RequestTypeNodes[0].ChildNodes)
         // Bind the data of the list to the combo box(cmbRequestType)

And the output of this code will be like this:



About Author

About Author I am as simple as c#. Gaurav
No Photo
Country India
Company N/A
Home Page N/A

Rate this article

Rating options from poor, fair, good, very good to excelent.  


Write your comment here.
Verification Code