http://hi.csdn.net/attachment/201106/13/10024661_13079415311kKR.jpg

解决方案 »

  1.   

    for循环遍历GV 
    row.FindControl("Checkbox")
      

  2.   

    for (int i = 0; i < this.GridView1.Rows.Count; i++)
                {
                    CheckBox cb = this.GridView1.Rows[i].Cells[1].FindControl("CheckBox1") as CheckBox;
                    //设定checkbox的选中状态
                    if (cb != null)
                    {
                        cb.Checked = true;
                    }
                }
      

  3.   

    protected void CheckAll_CheckedChanged(object sender,EventArgs e)
            {
                CheckBox ck = sender as CheckBox;
               
                if (ck != null)
                {
                    System.Web.UI.WebControls.GridView g = ck.NamingContainer.NamingContainer as System.Web.UI.WebControls.GridView;
                    for (Int32 i = 0; i < g.Rows.Count; i++)
                    {
                        (g.Rows[i].FindControl("CheckBox1") as CheckBox).Checked = ck.Checked;
                    }
                }
            }
            protected void CheckBox1_CheckedChanged(object sender,EventArgs e)
            {
                var count = 0;
                CheckBox ck = sender as CheckBox;
                if (ck != null)
                {
                    System.Web.UI.WebControls.GridView g = ck.NamingContainer.NamingContainer as System.Web.UI.WebControls.GridView;
                    for (Int32 i = 0; i < g.Rows.Count; i++)
                    {
                        if ((g.Rows[i].FindControl("CheckBox1") as CheckBox).Checked)
                        {
                            count++;
                        }
                    }
                    (g.HeaderRow.FindControl("CheckAll") as CheckBox).Checked =count==g.Rows.Count;
                }
            }参考
      

  4.   

    然后checkbox.checked=true
    呵呵.
    autopostback==true
      

  5.   


    for (int i=0;i<this.Repeater1.Items.Count;i++) 

    HtmlInputCheckBox check = (HtmlInputCheckBox)this.Repeater1.Items[i].FindControl("cbDelete1"); }或者
    foreach( RepeaterItem item in this.Repeater1.Items ) 

    HtmlInputCheckBox check = (HtmlInputCheckBox)item.FindControl("cbDelete1"); }
      

  6.   


     foreach (Control c in this.rptTables.Controls)
        {
            CheckBox cbx = (CheckBox)c.FindControl("cbxId");
            if (cbx != null)
            {
                cbx.Checked = true;
            }
        }
      

  7.   

    #2,#3,#8的就可以搞定.repeater和gridview差不多的
      

  8.   

    为什么不用JS?,如果用的话,page还不用Postback呢。
      

  9.   

     for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                ck1 = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1")
                ck1.Checked=true;
      

  10.   

    我用的:
    protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
        {//复选///////你用Repeater1代替GridView1就可以了
            if (CheckBox2.Checked == true)
            {
                CheckBox2.Text = "全选";
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");                cbox.Checked = true;
                }
            }
            else
            {
                CheckBox2.Text = "全不选";
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");                cbox.Checked = false;
                }
            }
        }
      

  11.   


    不管你外围用什么控件来包,最终还不是操作checkbox