Bind XML Data to DropDownList Control Using in C#

Bind XML Data to DropDownList Control

Bind Extensible Markup Language (XML) Xml List Data Bind To Dropdownlist Control Using in Asp.Net C#.



                       HTML Coding

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
    <div align="center">
        <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>

                           C# Coding

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();

            DropDownList1.DataTextField = "coursename";

            DropDownList1.DataValueField = "courseid";

            DropDownList1.DataSource = ds;



First - Add NewWeb Form - Select Dropdownlist from


Next - Add - New Item - XML file

Select - Xml File - Add 

Add Course Details To Xml File

Next - Add Namespaces -  Bind DataTextfield & DataValueField


Post a Comment