http://www.koolsoft.com/DataGridCheckboxes.aspx

解决方案 »

  1.   

    select时同时将唯一标识id放到数据集中,然后绑定到datagrid的第一列,在显示数据时将
    第一列隐藏。//下面是删除按钮的代码-----------------------------------------------------
    ArrayList myAL = new ArrayList();
    foreach(DataGridItem ee in dgrdLeave.Items )
    {
    if(((CheckBox)ee.FindControl("chkItem")).Checked)
    myAL.Add(ee.Cells[0].Text.Trim());
    } if(myAL.Count>0)
    {
    for(int i= 0;i<myAL.Count;i++)
    fDel(myAL[i].ToString().Trim()); if(radlType.SelectedIndex == 0)
    {
    this.dgrdLeave.CurrentPageIndex =0;
    bindDeptData();
    }
    else
    {
    this.dgrdLeave.CurrentPageIndex =0;
    bindPersonData();
    }
    }
    else
    lblInfo.Text = "请选择要删除的条目!";
      

  2.   

    ArrayList a = new ArrayList();
    foreach(DataGridItem dgi in Items)
    {
    CheckBox cb = (CheckBox) dgi.Cells[0].Controls[0];
    if (cb.Checked)
    a.Add(dgi);
    }
    return a;最后返回的是选中的Items集合。
      

  3.   

    使checkbox.id 与 记录id设为相同如:id="031001"在datagrid的itemcreate事件中
    add.controls[]...
      

  4.   

    Dim chkSelected As CheckBox
     Dim i, c As Integer
     c = DataGrid1.Items.Count
    If (c = 0) Then
                Exit Sub
            End If
            For i = 0 To (c - 1)
                '从列表依次选取每行
                chkSelected = Nothing
                chkSelected = DataGrid1.Items(i).FindControl("check")
                If (Not (chkSelected Is Nothing)) Then
                End If
            Next