加一个模版列<ItemTemplate>
<asp:CheckBox...
</ItemTemplate>设置这个CheckBox的AutoPostBack为true,
当改变时,就可以在对应的程序中执行修改操作

解决方案 »

  1.   

    属性生成器 - 列 - 添加模板列 然后在模板列里面添加 checkbox
      

  2.   

    我晕~~
    大哥,我没VS。NET啊~
      

  3.   

    该地址里有源码下载:
    http://www.codeproject.com/useritems/DataGrid_CheckBox.aspIntroduction
    This simple Demo Project show, how you can add Checkboxes to the DataGrid Webcontrol. This Article shows Handling with automatic selection and getting the selected Checkboxes, too. select all / deselect all Items
    This simple method iterate to the grid and sets the Checked State of the Checkboxes in the Grid. And sets the Button Caption the + / -.  Private Sub selectAll()
            Dim oDataGridItem As DataGridItem
            Dim chkExport As System.Web.UI.WebControls.CheckBox        If cmdSelectAll.Text = "+" Then
                For Each oDataGridItem In dgMain.Items                chkExport = oDataGridItem.FindControl("chkExport")
                    chkExport.Checked = True
                Next            cmdSelectAll.Text = "-"
            Else
                For Each oDataGridItem In dgMain.Items
                    chkExport = oDataGridItem.FindControl("chkExport")
                    chkExport.Checked = False
                Next
                cmdSelectAll.Text = "+"
            End If
        End Subfind selected Items
    This method iterate to the Grid Items, and adds the selected Rows in a Array     Private Sub cmdFindSelected_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFindSelected.Click        Dim oDataGridItem As DataGridItem
            Dim chkExport As System.Web.UI.WebControls.CheckBox
            Dim oExArgs As New System.Collections.ArrayList()
            Dim sID As String
            
            For Each oDataGridItem In dgMain.Items            chkExport = oDataGridItem.FindControl("chkExport")
                If chkExport.Checked Then
                    sID = CType(oDataGridItem.FindControl("lblColumn"), Label).Text
                    oExArgs.Add(sID)
                End If
            Next    End Sub
      

  4.   

    我狂倒~~
    我这边是教育网不能出国~~
    而且这段代码只有服务器端处理代码,并没有生成DATAGRID的代码啊~
    请这位大哥把代码贴全好吗?小弟谢啦~~~
      

  5.   

    for(int i=0;i<DataGrid.Item.Count;i++)
    {
    加一个模版列<ItemTemplate>
    <asp:CheckBox...
    </ItemTemplate> 
     CheckBox myCB=(CheckBox)DataGrid.Item[i].FindControl("myCB"); 
      if(myCB.Checked==true)
      {
       //真的操作,修改数据库,再重载DataGrid
      }}}
    Good Luck!