gridview中的复选框始终为假[关闭]

问题描述 投票:-1回答:1

这是网格视图:

  <asp:GridView ID="gv_remote" runat="server"  ViewStateMode="Enabled" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4" >
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <div class="row">
                                                    <div class="col-md-5">
                                                        <asp:CheckBox ID="cb_select_remote" runat="server" Text="" />
                                                    </div>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                                    <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                                    <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                                    <RowStyle BackColor="White" ForeColor="#003399" />
                                    <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                                    <SortedAscendingCellStyle BackColor="#EDF6F6" />
                                    <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                                    <SortedDescendingCellStyle BackColor="#D6DFDF" />

                                    <SortedDescendingHeaderStyle BackColor="#002876" />

                                </asp:GridView>

这是VB代码:

For Each row As GridViewRow In gv_remote.Rows Dim ChkBoxRows As CheckBox = CType(row.FindControl("cb_select_remote"), CheckBox) If ChkBoxRows.Checked Then lblerr.Text = "Checked" End If Next

我尝试从“ cb_select_remote”获取布尔值,但始终返回false,我尝试从互联网上获取任何解决方案,但仍无法正常工作,您能告诉我代码发生了什么吗?谢谢

asp.net vba gridview aspxgridview
1个回答
0
投票

如果有加载事件,则必须放入If Not IsPostBack Then

© www.soinside.com 2019 - 2024. All rights reserved.