Link to home
Start Free TrialLog in
Avatar of david_evans_work
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.SqlDataAdapter
        Dim aDataset As New Data.DataSet("MyDataSet")

        aDataAdapter = New Data.SqlClient.SqlDataAdapter("dbo.[listing]", strConn)
        aDataAdapter.SelectCommand.CommandType = Data.CommandType.StoredProcedure
        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
Avatar of Nasser Hamdan
Nasser Hamdan
Flag of United Arab Emirates image

I assume that u need the text property for item?
DropDownList1.SelectedItem.Text

or something else?

Avatar of david_evans_work
david_evans_work

ASKER

i think so, on the page source i want it to look like this:

<option value="1218066267">Name (12345)</option>
ASKER CERTIFIED SOLUTION
Avatar of skiltz
skiltz
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial