listView中实现多选

来源:互联网 发布:网络文件系统 编辑:程序博客网 时间:2024/06/10 20:41

 protected void cbCheckAll0_CheckedChanged(object sender, EventArgs e)
    {
        if (cbCheckAll0.Checked)//如果全选的checkbox被选中
        {
            for (int i = 0; i < this.ListView1.Items.Count; i++)
            {
                CheckBox box = this.ListView1.Items[i].Controls[8].FindControl("CheckBox1") as CheckBox;//遍历listview中的下拉框
                box.Checked = true;//设成选中状态
            }

        }
        else
        {
            for (int i = 0; i < this.ListView1.Items.Count; i++)
            {
                CheckBox box = this.ListView1.Items[i].Controls[8].FindControl("CheckBox1") as CheckBox;
                box.Checked = false;
            }
        }
    }

原创粉丝点击