我添加了此代码以在我的网格中获得一个带有复选框的列:
<Columns>
<asp:TemplateField HeaderText="Visitor" HeaderStyle-Width="20" FooterStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="myCheckBox" runat="server"/>
</ItemTemplate>
<FooterStyle HorizontalAlign="Center" />
<HeaderStyle Width="20px" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
我想获取复选框的值,但我得到“对象引用未设置为对象的实例”。错误。这是我尝试调用它的地方,但出现错误:
Dim checkb As String
For Each row As GridViewRow In orderGrid.Rows
Dim chk As CheckBox = CType(row.FindControl("myCheckBox"), CheckBox)
**checkb = Request.Form("myCheckBox")**
Next row
知道如何获得复选框的正确值吗?