Hi i am trying to populate a dropdownlist from a database
i can add items to the drop down box but need for the each to have a different value aka
venueId.Items.Add(venueRead["ven_name"].ToString());
venueId.Value = venueRead["ven_id"].ToString() ;
thanks
dan
Hi,
you can use the DataValueField & DataTextField properties to easily set this.
Grz, Kris.
hi i tried to do this and it wasnt working
while(venueRead.Read()) { venueId.DataValueField = venueRead["ven_id"].ToString(); venueId.DataTextField = venueRead["ven_name"].ToString(); venueDisp.Controls.Add(new LiteralControl("<a href='#' onClick=\"courseGet('Venue<@.>" + venueRead["ven_id"].ToString() + "')\">" + venueRead["ven_name"].ToString() +"</a><br>")); }Hi,
sorry, I didn't get from your original question that you were looping through your datareader while adding new items to the dropdownlist.
You can do as following:
while(venueRead.Read())
{
DropDownList1.Items.Add(newListItem(venueRead["ven_name"].ToString(), venueRead["ven_id"].ToString()));
}
Grz, Kris.
heya mate thanks very much it works fine now i dont know you suppose how to get javascript to select the correct item in the drop down box with the value??
thanks
dan
Hi,
Capture_db:
get javascript to select the correct item in the drop down box with the value??
google is your friend in this case:http://www.mredkj.com/tutorials/tutorial003.html.
Grz, Kris.
0 comments:
Post a Comment