How to bind xml data with combobox using c#


how to bind xml data with combobox using c#

=================== START ===================



 XMLFile1.xml
===================


======================================



Form1.cs
===================

private void Form1_Load(object sender, EventArgs e)
        {
            DataBind();
        }
private void DataBind()
        {
            XmlTextReader Objxml = new XmlTextReader("C:\\Users\\nitin\\Documents\\Visual Studio 2010\\Projects\\WindowsFormsApplication1\\WindowsFormsApplication1\\XMLFile1.xml");
            DataSet objdataset = new DataSet();
            objdataset.ReadXml(Objxml);
            comboBox1.DataSource = objdataset.Tables[0];
            comboBox1.DisplayMember = "Name";
            comboBox1.ValueMember = "ID";
        }

======================================

Result :


=================== END ===================

Comments

Popular posts from this blog

Tree view in winforms using c#

how to Replace null value with 0 Using C#

how to fetch all HTML Table Records and modify all records accordingly using jquery and Javascript