Dropdownlist with XML file
How to bind a dropdownlist with xml file.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Jul 25, 2012, 8:36 AM
student.xml
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Dropdownlist_with_XML_file._Default" %>
Thanks
If this post helps you mark it as answer
Santhosh Kumar JayaramanPosted Jul 25, 2012, 1:08 AM
//the path in which XML file is saved
string path = "D:\\Santhosh\\XMLFile1.xml";
DataSet ds=new DataSet();
//Reading XML file and copying to dataset
ds.ReadXml(path);
Then as usual you can bind this dataset to your dropdownlist.
ddl1.Datasource=ds;
Please look into the below article to know how to convert xml to dataset and vice versa.
http://www.c-sharpcorner.com/UploadFile/1a81c5/populating-values-from-xml-to-gridview-and-from-gridview-to/