//page load event handler
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//Function to populate dropdownlist from xml
PopulatedropdowndatafromXMLfile();
}
}
//Populates the dropdownlist from xml file
public void PopulatedropdowndatafromXMLfile()
{
string XMLfilePath = Server.MapPath("~/XMLResources/DotnetXMLFile.xml");
ds.ReadXml(XMLfilePath);
DataSet ds = new DataSet();ddllocation.DataSource = ds;
ddllocation.DataTextField = "Name";
ddllocation.DataValueField = "ID";ddllocation.DataBind();
}
now press F5 and come out od debuging mode. You will get following output.