你是不是没有把生成的代码 写在 if(!IsPostBack) 中

解决方案 »

  1.   

    为DataGrid添加CheckBox控件  
    作者: 孟宪会 
    http://sz.luohuedu.net/xml/ShowDetail.asp?id=FF130C7F-3650-4DA6-8943-8AA4AF3E3459
      

  2.   

    for (int i=0;i<Count;i++)
    {
    CheckBox CB;
    CB=(CheckBox)DataGrid1.Items[i].Cells[0].FindControl("CheckBoxKC");
    if (CB.Checked==true)
    {
    ////处理相应问题 }
    }其中:CheckBokKC为模版列中加入的CheckBox控件的ID
      

  3.   

    public void check_changed(object obj,EventArgs e)
    {

    for(int i=0;i<mydg.Items.Count;i++){
                
    CheckBox cbx=(CheckBox)mydg.Items[i].Cells[0].FindControl("check");

    if(cbx.Checked==true)
    {
    //处理相应问题代码
    }
    }
    }