Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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

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)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...