I know there is many questions about this and i have looked at the answers but nothing works for me when i test the answers they got.
My problem is that i can´t reach the method on server side when the checkbox is checked or unchecked. Nothing happens.
Here is my code:
The repeater:
<asp:Repeater ID="rptTimeWeekTable" OnItemDataBound="rptrptTimeWeekTable_ItemDataBound" OnItemCommand="rptTimeWeekTable_ItemCommand" runat="server">
The checkbox:
<asp:CheckBox ID="chBoxSum" runat="server" Enabled="true" OnCheckedChanged="chBoxSum_CheckedChanged" AutoPostBack="true"></asp:CheckBox>
Code behind:
protected void chBoxSum_CheckedChanged(object sender, EventArgs e)
{
CheckBox chBox = (CheckBox)sender;
int rowIndex = ((RepeaterItem)chBox.NamingContainer).ItemIndex;
CheckBox chBoxMon = rptTimeWeekTable.Items[rowIndex].FindControl("chBoxMonday") as CheckBox;
CheckBox chBoxTue = rptTimeWeekTable.Items[rowIndex].FindControl("chBoxTuesday") as CheckBox;
CheckBox chBoxWed = rptTimeWeekTable.Items[rowIndex].FindControl("chBoxWednesday") as CheckBox;
CheckBox chBoxThu = rptTimeWeekTable.Items[rowIndex].FindControl("chBoxThursday") as CheckBox;
CheckBox chBoxFri = rptTimeWeekTable.Items[rowIndex].FindControl("chBoxFriday") as CheckBox;
CheckBox chBoxSat = rptTimeWeekTable.Items[rowIndex].FindControl("chBoxSaturday") as CheckBox;
CheckBox chBoxSun = rptTimeWeekTable.Items[rowIndex].FindControl("chBoxSunday") as CheckBox;
if (chBox.Checked == true)
{
chBoxMon.Checked = true;
chBoxTue.Checked = true;
chBoxWed.Checked = true;
chBoxThu.Checked = true;
chBoxFri.Checked = true;
chBoxSat.Checked = true;
chBoxSun.Checked = true;
}
else
{
chBoxMon.Checked = false;
chBoxTue.Checked = false;
chBoxWed.Checked = false;
chBoxThu.Checked = false;
chBoxFri.Checked = false;
chBoxSat.Checked = false;
chBoxSun.Checked = false;
}
}
protected void rptTimeWeekTable_ItemCommand(object source, RepeaterCommandEventArgs e)
{
}
Hope you guys can help me.
Aucun commentaire:
Enregistrer un commentaire