Bind XML Data to DropDownList Control
Bind Extensible Markup Language (XML) Xml List Data Bind To Dropdownlist Control Using in Asp.Net C#.
DEMO
Download
HTML Coding
C# Coding
Bind Extensible Markup Language (XML) Xml List Data Bind To Dropdownlist Control Using in Asp.Net C#.
DEMO
Download
HTML Coding
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
Course
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class Xml : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("XMLFile.xml"));
DropDownList1.DataTextField = "coursename";
DropDownList1.DataValueField = "courseid";
DropDownList1.DataSource = ds;
DropDownList1.DataBind();
}
}
}
0 comments:
Post a Comment