Databound DropDownList is Empty

  • Thread starter Thread starter ssims
  • Start date Start date
S

ssims

For some reason my databound DropDownList will not populate. I've
tried a variety of things...here's the latest.

- I pulled a DropDownList on to the page.
- Then I pulled a SqlDataAdapter and set the select query to "SELECT *
FROM Items".
- I chose Generate DataSet... from the SqlDataAdapter's properties.
- I set the DataSource, DataMember, DataTextField, and DataValueField
properties in the Properties window.
- Then I put DropDownList1.DataBind() in the Page_Load event.

The DropDownList is empty, but if I go to the SqlDataAdapter and chose
"Preview Data" it shows the data properly.

I've also tried putting sqlDataAdapter1.Fill(DataSet1,"Items") in the
Page_Load event prior to the DropDownList1.DataBind() code.

Any help would be greatly appreciated. Thanks.

-Sean
 
Is there any code actually telling the dataset to be populated with data?

This is why it is best to not use the designer. You end up relying on it to
do thing, and you have no idea what is actually going on. Just write the
data access code yourself, you will be better off.
 
I agree with MArina.
By the way have u wrapped the code in !Page.Postback. in the Page_load?
Patrick
 
Back
Top