herodotus299 Posted July 21, 2006 Posted July 21, 2006 I have a weird problem. I'm trying to populate a drop down list (ddlField01). When I debug, I can see the data in my Dataset, but after the auto postback, I don't see the value displayed. Here is what I'm using. ddlField01.Text = dsMyDataset.Tables[0].Rows[0].ItemArray[1].ToString(); If I change it to a text box, it works fine. txtlField01.Text = dsMyDataset.Tables[0].Rows[0].ItemArray[1].ToString(); The syntax I use for the drop down list is used in a few other drop downs without problem. Any ideas? Thanks, Jeremy Quote
Administrators PlausiblyDamp Posted July 22, 2006 Administrators Posted July 22, 2006 Are you doing anything else with the DropDownList like databinding? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted July 24, 2006 Posted July 24, 2006 To populate a dataset you must use the following: ddlField01.datasource = dsMyDataset.Tables[0]; ddlField01.databind(); In the event that you have more that one column in your datatable, you need to specify what column you want to display and optionally what column you want to use as a reference column. ddlField01.DataTextField = "<ColumnName>" ddlField01.DataValueField = "<ColumnName>" Mike55. I have a weird problem. I'm trying to populate a drop down list (ddlField01). When I debug, I can see the data in my Dataset, but after the auto postback, I don't see the value displayed. Here is what I'm using. ddlField01.Text = dsMyDataset.Tables[0].Rows[0].ItemArray[1].ToString(); If I change it to a text box, it works fine. txtlField01.Text = dsMyDataset.Tables[0].Rows[0].ItemArray[1].ToString(); The syntax I use for the drop down list is used in a few other drop downs without problem. Any ideas? Thanks, Jeremy Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.