Expand|Select|Wrap|Line Numbers
- <asp:DropDownList ID="DropDownList5" runat="server" AppendDataBoundItems="True"
- DataSourceID="SqlDataSource6" DataTextField="StaffName"
- DataValueField="StaffName" SelectedValue='<%# Bind("LetterName") %>'
- Width="155px">
- <asp:ListItem Value=""> </asp:ListItem>
- </asp:DropDownList>
Expand|Select|Wrap|Line Numbers
- Protected Sub Formview1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.PreRender
- Dim dropdown As DropDownList
- Dim listvalue As TextBox
- dropdown = FormView1.FindControl("dropdownlist5")
- listvalue = FormView1.FindControl("textbox1")
- dropdown.Items.Add(New ListItem(listvalue.Text, listvalue.Text))
- End Sub
"'DropDownList5' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value"
This is the bit I dont understand because the value does now exist in the list of items as it was added in from the textbox value. Does it try to do the selectedValue before adding my list item? If so how can I add the list item first, or do I need to set the selectedValue in the code after adding the list item?