Click here to Skip to main content
15,885,810 members
Please Sign up or sign in to vote.
1.40/5 (2 votes)
See more:
In my edit page....how to bind a dropdown value among values in dropdown....for Example
I have DropDownList (Dynamically Bind this List from DB)
1.India
2.America
3.China
4.Japan


Among these list....I want to Bind America(In my Edit Page).......How to do this???????????


Note: If i select Edit Button in my Gridview,at this situation I want to bind the America in Dropdown among the List Items
Posted
Comments
Sunasara Imdadhusen 13-May-14 8:25am    
No body written code for you! you should try yourself and ask for help if you really try lot

C#
string sQuery = "SELECT CountryID, CountryName FROM COUNTRY";
DataTable dtData = new DataTable();
SqlConnection oSQLConnection = new SqlConnection("sConString");
SqlCommand cmd = new SqlCommand(sQuery, oSQLConnection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
oSQLConnection.Open();
da.Fill(dtData);
da.Dispose();

DropDownList1.DataSource = dtData;
DropDownList1.DataValueField = "CountryID";
DropDownList1.DataTextField = "CountryName";
DropDownList1.DataBind();
 
Share this answer
 
Comments
phmani469 13-May-14 12:22pm    
Read my question clearly.......I want to bind a single value among the list when the page is loading

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900