david_evans_work
asked on
Multiple values in db generated dropdownlist
I have a stored procedure which returns data to a dropdownlist in asp.net VB the back end looks like this:
Dim aDataAdapter As Data.SqlClient.SqlDataAdap ter
Dim aDataset As New Data.DataSet("MyDataSet")
aDataAdapter = New Data.SqlClient.SqlDataAdap ter("dbo.[ listing]", strConn)
aDataAdapter.SelectCommand .CommandTy pe = Data.CommandType.StoredPro cedure
aDataAdapter.Fill(aDataset , "Groups")
Dim Table As Data.DataTable = aDataset.Tables("Groups")
DropDownList1.DataSource = Table
DropDownList1.DataBind()
And the front end looks like this:
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="textstyle" AppendDataBoundItems="True " DataTextField="name" DataValueField="id">
<asp:ListItem Value="--">--Please Select--</asp:ListItem>
</asp:DropDownList>
This works fine but how can i get not only the name in the dropdown list but also other data as well, not in the value field but in the text part that the user sees: example:
Name | Country ID
Thanks in advance
Dim aDataAdapter As Data.SqlClient.SqlDataAdap
Dim aDataset As New Data.DataSet("MyDataSet")
aDataAdapter = New Data.SqlClient.SqlDataAdap
aDataAdapter.SelectCommand
aDataAdapter.Fill(aDataset
Dim Table As Data.DataTable = aDataset.Tables("Groups")
DropDownList1.DataSource = Table
DropDownList1.DataBind()
And the front end looks like this:
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="textstyle" AppendDataBoundItems="True
<asp:ListItem Value="--">--Please Select--</asp:ListItem>
</asp:DropDownList>
This works fine but how can i get not only the name in the dropdown list but also other data as well, not in the value field but in the text part that the user sees: example:
Name | Country ID
Thanks in advance
ASKER
i think so, on the page source i want it to look like this:
<option value="1218066267">Name (12345)</option>
<option value="1218066267">Name (12345)</option>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DropDownList1.SelectedItem
or something else?