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
Post a Comment