Dropdownlist with XML file
How to bind a dropdownlist with xml file.
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Santhosh Kumar JayaramanRank #563 · 4.3K reputationPosted Jul 24, 2012, 9:08 PM EDT
//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/
Satyapriya NayakRank #47 · 31.5K reputationPosted Jul 25, 2012, 4:36 AM EDT
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