User2015884762 posted
Hi, let me explain the error scenario
I select the checkbox, there are 5 of them and the repeater control gets populated accordingly. Here, there are no issues during the selection.
Then, I go and unselect the checbox for the first row, the page refreshes and the checkbox remains selected.
I try again , and at the second time, the checkbox would get deselected fine.
Why is this happening. This is my code, am I missing something.
public void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
//List<string> user_select_weeks_list = new List<string>();
AllLists create1 = new AllLists();
for (int i = 0; i < rptItemsInCart.Items.Count; i++)
{
CheckBox ref_to_checkBox = (CheckBox)rptItemsInCart.Items[i].FindControl("Checkbox1");
if (ref_to_checkBox.Checked)
{
Ok_prompt_to_upload_Button.Visible = true;
ref_to_checkBox.ID = "Week" + (i + 1);
Label2.Text = ref_to_checkBox.ID;
create1.user_select_weeks_list.Add(ref_to_checkBox.ID);
//user_select_weeks_list.Add(ref_to_checkBox.ID);
}
else
{
create1.user_select_weeks_list.Remove(ref_to_checkBox.ID);
}
}
selected_weeks_repeater.DataSource = create1.user_select_weeks_list;
selected_weeks_repeater.DataBind();
}
public class AllLists
{
public List<string> user_select_weeks_list { get; set; }
public AllLists()
{
this.user_select_weeks_list = new List<string>();
}
}
I did some debugging, but of course, I was not able to debug as the checkbox did not get fired, but i did see this exception in Visual Studio
'this.IsValid' threw an exception of type 'System.Web.HttpException'
"Page.IsValid cannot be called before validation has taken place. It should be queried in the event handler for a control that has CausesValidation=True and initiated the postback, or after a call to Page.Validate."