asp.net web cs后台触发控件事件问题
前台一个checkboxlist和一个全选的checkbox后台问题是全选时CheckedChanged如何触发checkboxlistselectedIndexChan...
前台一个checkboxlist 和一个 全选的checkbox
后台 问题是全选时CheckedChanged如何触发checkboxlist selectedIndexChanged事件?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetReportList();
}
}
private void GetReportList()
{
DataTable dtStudent = new StudentDal().GetInform();
ckbStudent.DataTextField = "NAME";
ckbStudent.DataValueField = "ID";
ckbStudent.DataSource = dtStudent;
ckbStudent.DataBind();
}
protected void ckbStudent_SelectedIndexChanged(object sender, EventArgs e)
{
int id = new Random().Next(0,100);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('test! " +id+ "');</script>");
}
//问题是下面的全选时如何触发上面的checkboxlist selectedIndexChanged事件?
protected void chkAll1_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < ckbStudent.Items.Count; i++)
{
ckbStudent.Items[i].Selected = chkAll1.Checked;
}
} 展开
后台 问题是全选时CheckedChanged如何触发checkboxlist selectedIndexChanged事件?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetReportList();
}
}
private void GetReportList()
{
DataTable dtStudent = new StudentDal().GetInform();
ckbStudent.DataTextField = "NAME";
ckbStudent.DataValueField = "ID";
ckbStudent.DataSource = dtStudent;
ckbStudent.DataBind();
}
protected void ckbStudent_SelectedIndexChanged(object sender, EventArgs e)
{
int id = new Random().Next(0,100);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('test! " +id+ "');</script>");
}
//问题是下面的全选时如何触发上面的checkboxlist selectedIndexChanged事件?
protected void chkAll1_CheckedChanged(object sender, EventArgs e)
{
for (int i = 0; i < ckbStudent.Items.Count; i++)
{
ckbStudent.Items[i].Selected = chkAll1.Checked;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询