前台代码:

<Columns>
<asp:TemplateField HeaderText="选择">
<HeaderStyle HorizontalAlign="Center" Height="25px" Width="45px" />
<ItemTemplate>
<asp:CheckBox ID="ckb" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="sid" HeaderText="编号" />
<asp:BoundField DataField="cname" HeaderText="姓名" />
</Columns>

后台代码:

foreach (GridViewRow gvr in this.GridView1.Rows) 
{ 
     Control ctl = gvr.FindControl("ckb"); 
     CheckBox ck = (CheckBox)ctl; 
     if (ck.Checked) 
     { 
         TableCellCollection cell = gvr.Cells; 
         string wid += cell[1].Text+","; 
     } 
} 

相关文章:

  • 2022-01-06
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2021-07-20
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案