0

How do I bind a dropdown in a Listview to the database and the dropdown list.

E.g. Drop down has two choices Left and Right. The dropdown writes back to the database. Issue is that I have records in the database that already have 'Left' or 'Right' recorded for that data item.

I don't know how to include the evaluated or bound item in the drop down list. Does this make sense to anyone!!!??????

                <td><asp:DropDownList ID="ddLeftOrRight" DataTextField=<%# Bind("LeftOrRight") %> runat ="server" >
                <asp:ListItem Value= ""></asp:ListItem>
                <asp:ListItem Value="L"></asp:ListItem>
                <asp:ListItem Value="R"></asp:ListItem>
            </asp:DropDownList></td>
2
  • Why do you bind to DataTextField - DataTextField=<%# Bind("LeftOrRight") %> and then again provide ListItem values manually? Nov 30, 2018 at 17:17
  • It's messy! The web form captures data. But sometimes the user has already opened it and saved part of the form already. So if they have I want that field to display the information previously entered rather than show the drop down list. Nov 30, 2018 at 18:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.