protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        this.Label1.Text = "";
        CheckBox ck = (CheckBox)this.GridView1.Rows[e.RowIndex].Cells[4].Controls[0];
        
        bool b = ck.Checked;
        if (!b)
        {
            string uname = this.GridView1.Rows[e.RowIndex].Cells[1].Text.ToString();
            string date = this.GridView1.Rows[e.RowIndex].Cells[3].Text.ToString();
            string num = this.GridView1.Rows[e.RowIndex].Cells[2].Text.ToString();            if (bs.doProcedure("exec prc_addcoins '" + uname + "','" + date + "'," + num))
            {
                this.Label1.Text = "<script>alert('处理成功')</script>";
                this.fillTable();
            }
        }
        else
        {
            this.Label1.Text = "<script>alert('已经处理')</script>";
本人想在gridview中增加checkbox选中后更新数据功能,但调试后checkbox不可选,求各位大虾帮忙求解。

解决方案 »

  1.   


    CheckBox ck = (CheckBox)this.GridView1.Rows[e.RowIndex].FindControl("controlName");
    这样试一试
      

  2.   

    本帖最后由 net_lover 于 2012-05-16 09:11:47 编辑
      

  3.   

    如果你不想改模板列,你可以这样
    CheckBox ck = (CheckBox)this.GridView1.Rows[e.RowIndex].Cells[4].Controls[0];
    ck.Enabled=true;
      

  4.   

    本帖最后由 net_lover 于 2012-05-16 09:16:03 编辑
      

  5.   

    除了代码之外,还有一个很细节的问题,就是当datagridview设为ReadOnly属性时候,添加的CheckBox是不可选的,所以不能把dataGridView设为只读的