I am trying to following the code example thats in a old thread for checkboxlist and ran into the following error.
Not sure whats going wrong.
public void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
CheckBoxList cbl1 = (CheckBoxList)this.FormView1.FindControl("Review");
if (cbl1 != null)
{
SqlDataSource1.UpdateParameters["Review"].DefaultValue = cbl1.SelectedValue;
//assign other parameters
SqlDataSource1.Update();
}
}
Aspx
Review:
<asp:CheckBoxList ID="Review" runat="server" SelectedValue='<%#Bind("Review") %>'>
<asp:ListItem Value="a123" Text="a123"></asp:ListItem>
<asp:ListItem Value="b1234" Text="b1234"></asp:ListItem>
<asp:ListItem Value="c1235" Text="c1235"></asp:ListItem>
<asp:ListItem Value="d1236" Text="d1236"></asp:ListItem>
<asp:ListItem Value="e1237" Text="e1237"></asp:ListItem>
<asp:ListItem Value="f1238" Text="f1238"></asp:ListItem>
<asp:ListItem Value="g1239" Text="g1239"></asp:ListItem>
<asp:ListItem Value="h1230" Text="h1230"></asp:ListItem>
<asp:ListItem Value="i1231" Text="i1231"></asp:ListItem>
</asp:CheckBoxList>
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: 'cbl1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
Not sure whats going wrong.
public void FormView1_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
CheckBoxList cbl1 = (CheckBoxList)this.FormView1.FindControl("Review");
if (cbl1 != null)
{
SqlDataSource1.UpdateParameters["Review"].DefaultValue = cbl1.SelectedValue;
//assign other parameters
SqlDataSource1.Update();
}
}
Aspx
Review:
<asp:CheckBoxList ID="Review" runat="server" SelectedValue='<%#Bind("Review") %>'>
<asp:ListItem Value="a123" Text="a123"></asp:ListItem>
<asp:ListItem Value="b1234" Text="b1234"></asp:ListItem>
<asp:ListItem Value="c1235" Text="c1235"></asp:ListItem>
<asp:ListItem Value="d1236" Text="d1236"></asp:ListItem>
<asp:ListItem Value="e1237" Text="e1237"></asp:ListItem>
<asp:ListItem Value="f1238" Text="f1238"></asp:ListItem>
<asp:ListItem Value="g1239" Text="g1239"></asp:ListItem>
<asp:ListItem Value="h1230" Text="h1230"></asp:ListItem>
<asp:ListItem Value="i1231" Text="i1231"></asp:ListItem>
</asp:CheckBoxList>
Parameter name: value
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: 'cbl1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value