上面写少了。。data是一个dataset

解决方案 »

  1.   

    for(int i=0;i< Groupdata.Tables[0].Rows.Count ;i++)
    {
          for (int j = 0; j < this.DataGrid1.Items.Count; j++)
    CheckBox mycb=(CheckBox)DataGrid1.Items[j].FindControl("mycb");
                      { if(Groupdata.Tables[0].Rows.Find(DataGrid1.DataKeys[i])!=null)
                       
    { mycb.Checked=true;
    }
    } }
    代码我是这样写的。。groupdata是个dataset  可是运行后老是提示没设置主键 ,到底要怎么做呢?
      

  2.   

    设置你 DataGrid 的 DataKeyField.
      

  3.   

    datagrid的datakeyfield设置了。。
    各位高手最好说说这个问题的解决方法 , 就是 我有一个表 里面两列 “groupid” “groupname”
    我把他棒定到一个datagrid里面去 有个摸版列(checkbox) datakeyfield是设置groupid
    还有另外一个关系表 table2 里面是 memberid groupid两列 表示成员和组的关系 我读出了table2里面的一组groupid 之后想让datagrid根据table2.groupid自己设置摸版列的checkbox自己选上。请问这种功能一般是用什么方法实现的 我是在web下做的