Monday, 20 August 2012

How to bind the selected value of a DropDownList

// Select * from Countries
// Select CustID,CountryID from Customers where CustID=1
DataSet ds = new DataSet();
da.Fill(ds, "Countries");
ddl.DataSource = ds.Tables[0];
ddl.DataTextField = "CountryName";
ddl.DataValueField = "CountryID";
ddl.SelectedValue = ds.Tables[1].Rows[0]["CountryID"].ToString();
ddl.DataBind();

O/p:    

Tags: asp.net, binding, selected value, data base

No comments:

Post a Comment

Parsing JSON w/ @ symbol in it

To read the json response like bellow @ concatenated with attribute                             '{ "@id": 1001, "@name&q...