Databound DropDownList is Empty

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
 
M

Marina Levit [MVP]

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.
 
P

Patrick.O.Ige

I agree with MArina.
By the way have u wrapped the code in !Page.Postback. in the Page_load?
Patrick
 
P

pintu

I thnk u missed out the DataTextField Property.Just check that..

Regards
Priyabrata
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top