How To Bind XML File With Drop Down List In Visual Studio 2010

Hello Friends Today You will learn how to make new web site into visual studio 2010
Step 1: Start to visual studio 2010 click on start then programme-> then click on Visual Studio 2010 and At Start it will give you below give look.

Step 2: Now Make New Web Site INto Visual Studio 2010 and Choose C Sharp Language.

Step 3: Now Make a New Employees.xml File

Step 4: Now Click On Default.aspx Page and Go into Source File and Write Down Below Given Source

Welcome to Visual Studio 2010!

To learn about Bind of Drop Down List With XML

Step 5: Now Into Code File of Default.aspx PAge Write down below given code
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind_DropDownList();
}
}
public void Bind_DropDownList()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(“Employees.xml”));
DataView dv = new DataView();
dv = ds.Tables[0].DefaultView;
dv.RowFilter = “Esal>=2000”;
dv.Sort = “Ename ASC”;
ddlEmp.DataSource = dv;
ddlEmp.DataTextField = “Ename”;
ddlEmp.DataValueField = “EmpNo”;
ddlEmp.DataBind();

}
STep 6: Now Go On Design View of Your Page and You Will Get As Given Below Look and Press F5 and enjoy in Programming World.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s