Link to home
Create AccountLog in
Avatar of mlg101
mlg101Flag for United States of America

asked on

Databound DDL not keeping all list items

I have a ddl, which is not initially bound to a datasource with 4 listItems. User selects one list item, then clicks the save button, which inputs the selected item into database. When I recall the selected item back to the ddl on page load, I have the ddl databound, and it recalls the item that was selected just fine, but it does not show the other list items in the ddl. I need to have all the items still available, in case the user needs to change their selection.

Here is my code:

Script:

Dim Adapter As New SqlDataAdapter("SELECT * FROM Orders Where OrdersID = " & list1.SelectedItem.Value, "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Client.mdf;Integrated Security=True;User Instance=True")

Dim Dataset As New DataSet

Adapter.Fill(Dataset, "Orders")

Me.Representing.DataMember = "Orders"

Me.Representing.DataSource = Dataset

Me.Representing.DataTextField = "Representing"

Me.Representing.DataValueField = "OrdersID"

Me.Representing.DataBind()

 Content:

<asp:DropDownList ID="Representing" runat="server" Height="18px"

Font-Size="X-Small" Width="129px">

<asp:ListItem Value="Plaintiff">Plaintiff</asp:ListItem>

<asp:ListItem Value="Defendant">Defendant</asp:ListItem>

<asp:ListItem Value="Petitioner">Petitioner</asp:ListItem>

<asp:ListItem Value="Respondent">Respondent</asp:ListItem>

</asp:DropDownList>
ASKER CERTIFIED SOLUTION
Avatar of Solar_Flare
Solar_Flare

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of mlg101

ASKER

Thank you! Worked great!