asp.net 获取动态绑定的CheckBoxList 的选中项

[复制链接]
查看11 | 回复1 | 2010-10-7 16:53:35 | 显示全部楼层 |阅读模式
用数组绑定CheckBoxList 然后点击按钮删除选中项,单步调试发现CheckBoxList1.Items.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.Selected)

{

CheckBoxList1.Items.RemoveAt(i);

}

}

}

回复

使用道具 举报

千问 | 2010-10-7 16:53:35 | 显示全部楼层
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{
string[] book = Session["Book"].ToString().Split(',');
this.CheckBoxList1.DataSource = book;
this.CheckBoxList1.DataBind();
}}改成
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行