用模板列就可以在datagrid中加入带控件的列了

解决方案 »

  1.   

    <asp:datagrid id="DataGrid1" runat="server">
    每一行的末尾增加复选框:<ItemTemplate>
    <asp:CheckBox Runat=server ID="repealnumber" Checked=false>
    </asp:CheckBox>
    </ItemTemplate>.cs文件内容int k=0;
    int i=DataGrid1.DataKeys.Count;
    for (int j=0;j<i;j++)
    {   
    li_col=j+3;
    ls_col="_ctl0:DataGrid1:_ctl"+li_col.ToString()+":repealnumber";//获取复选框的ID
    ls_col1="_ctl0:DataGrid1:_ctl"+li_col.ToString()+":Linkbutton1";
    ls_col2="_ctl0:DataGrid1:_ctl"+li_col.ToString()+":Label2";
        
    if  (((CheckBox)Page.FindControl(ls_col)).Checked)
    {
                         //所要进行的操作
    }