我知道有很多这方面的问题,我看了答案,但是当我测试他们得到的答案时,没有什么对我有用。
我的问题是,当选中或取消选中复选框时,我无法访问服务器端的方法。没有任何事情发生。
这是我的代码:
转发器:
<asp:Repeater ID="rptTimeWeekTable" OnItemDataBound="rptrptTimeWeekTable_ItemDataBound" OnItemCommand="rptTimeWeekTable_ItemCommand" runat="server">
复选框:
<asp:CheckBox ID="chBoxSum" runat="server" Enabled="true" OnCheckedChanged="chBoxSum_CheckedChanged" AutoPostBack="true"></asp:CheckBox>
代码背后:
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)
{
}
希望你们能帮帮我。