DropDownList
-
rdr is a SqlDataReader. rdr have a table in which data are "select BestForName,BestForID from BestForTable" ddlBestFor is a drop down list. when I try ddlBestFor.items.add(rdr["BestForName"]); I'm getting for ddlBestFor text : all BestForName value: 0,1,2,........ But I want to add like text : all BestForName value: all BestForID I need hardly. thanks a lot.
You get the best out of others when you give the best of yourself.
-
rdr is a SqlDataReader. rdr have a table in which data are "select BestForName,BestForID from BestForTable" ddlBestFor is a drop down list. when I try ddlBestFor.items.add(rdr["BestForName"]); I'm getting for ddlBestFor text : all BestForName value: 0,1,2,........ But I want to add like text : all BestForName value: all BestForID I need hardly. thanks a lot.
You get the best out of others when you give the best of yourself.
Use the following code objDataSet will have the set of records which are retrived using select query. ddlBestFor.DataValueField = objDataSet.Tables[0].Columns[1].ToString(); ddlBestFor.DataTextField = objDataSet.Tables[0].Columns[0].ToString(); ddlBestFor.DataSource = objDataSet.Tables[0]; ddlBestFor.DataBind(); ddlBestFor.Items.Insert(0, "Select"); Bhanu
-
rdr is a SqlDataReader. rdr have a table in which data are "select BestForName,BestForID from BestForTable" ddlBestFor is a drop down list. when I try ddlBestFor.items.add(rdr["BestForName"]); I'm getting for ddlBestFor text : all BestForName value: 0,1,2,........ But I want to add like text : all BestForName value: all BestForID I need hardly. thanks a lot.
You get the best out of others when you give the best of yourself.
u have to set DataValue property also along with DataText one way of doing this is the mentioned by other fellow in the above post