Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding a Drop Down List 1

Status
Not open for further replies.

chezealot9

Programmer
Jun 17, 2003
50
0
0
US
Hey Guys, I have a drop down list that I want to be able to run off a query and Im having a heck of a time binding the data to it because I'm new to asp.net and Visual Studio. Basically I set up the sql connection for the page, then the data adaptor, then the dataset, and Ive tried binding the drop down menu to the data set now, but it doesn't seem to be getting the data still, no errors just no data, what am I missing? Do I have to call something else to set it up too? Im working in Visual Studio.net, and would massively appreciate any help you guys can lend.
 
Something like this:
Add to Page_Load and replace with your control names...

If Not Page.IsPostBack Then
SqlDataAdapter1.Fill(DataSet1)
DropDownList1.DataSource = DataSet1
DropDownList1.DataTextField = "Whatever you Want"
DropDownList1.DataValueField = "Whatever"
DropDownList1.DataBind
End IF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top