asp.net 获取动态绑定的CheckBoxList 的选中项
用数组绑定CheckBoxList然后点击按钮删除选中项,单步调试发现CheckBoxList1.Items[i].Selected不管是否有选中项都为false,不知道...
用数组绑定CheckBoxList 然后点击按钮删除选中项,单步调试发现CheckBoxList1.Items[i].Selected不管是否有选中项都为false,不知道是怎么回事。
protected void Page_Load(object sender, EventArgs e)
{
string[] book = Session["Book"].ToString().Split(',');
this.CheckBoxList1.DataSource = book;
this.CheckBoxList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
CheckBoxList1.Items.RemoveAt(i);
}
}
} 展开
protected void Page_Load(object sender, EventArgs e)
{
string[] book = Session["Book"].ToString().Split(',');
this.CheckBoxList1.DataSource = book;
this.CheckBoxList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
CheckBoxList1.Items.RemoveAt(i);
}
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询