I'm trying to bind to a drop down menu in a form view and can't seem to get it to work. Using 2.0 c#.
<asp:TextBox ID="txtState" runat="server" Text='<%# Eval("State") %>'></asp:TextBox>
show's my state; however I want it selected in a drop down menu.
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Eval("State") %>'>
The above gives me the error below:
'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
here is my code in the codebehind:
private void BindEDetails(string authID)
//bind data to details
FormView1.Visible = true;
SqlCommand cmd = new SqlCommand("uspGetClientById", new SqlConnection(myConn));
cmd.CommandType = System.Data.CommandType.StoredProcedure;
FormView1.DataSource = cmd.ExecuteReader();