日期:2014-05-18 浏览次数:20685 次
<asp:GridView ID="gv_LoanList" runat="server" AllowPaging="True" PageSize="10" CssClass="desktable" AllowSorting="True" EnableModelValidation="True" AutoGenerateColumns="False" OnPageIndexChanging="gv_LoanList_PageIndexChanging" ondatabound="gv_LoanList_DataBound"> <Columns> <asp:TemplateField HeaderText="选择" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:CheckBox ID="cbo_checked" runat="server" ToolTip='<%#Eval("LoanHeadID") %>' /> </ItemTemplate> <ItemStyle HorizontalAlign="Center" /> </asp:TemplateField> </Columns> <PagerStyle CssClass="pager noborder" /> <HeaderStyle CssClass="header" /> </asp:GridView>
for(int i=0;i<gv_LoanList.Rows.Count();i++) { CheckBox cb=gv_LoanList.Rows[i].FindControl("cbo_checked") as CheckBox ; } foreach(GridViewRow row in gv_LoanList.Rows) { CheckBox cb=row .FindControl("cbo_checked") as CheckBox ; }
------解决方案--------------------
foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); if (chkId.Checked == true) { //复选框选中 } }