wtbonnell Posted October 6, 2003 Posted October 6, 2003 VB.NET I have a table (tableName) that has 3 columns: Name, Number, and ID. I want to be able to bind just the ID column to a dropdown list. This is what I have so far, what goes into the datasource? <asp:dropDownList id="ddl_ID" datasource='<%# ??? %>' runat="server"/> Thanks, Bill Quote
Moderators Robby Posted October 7, 2003 Moderators Posted October 7, 2003 Get rid of the 'datasource' you have within your asp tags, instead do something like this in your code-behind page... Friend Sub LoadDropDown() Dim dv As DataView With ddl_ID dv = 'get your dataview here .DataSource = dv .DataMember = "tableName" .DataValueField = "id" .DataTextField = "name" .DataBind() End With End Sub To later get the user's selection... Dim mySelectedID as integer = ddl_ID.SelectedItem.Value dim mySelectedName as string = ddl_ID.SelectedItem.Text Quote Visit...Bassic Software
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.