C
Carlos
Hi all,
I have a page that inherits from a master page and it contains a gridview
with a checkbox as a field.
My problem is that when I check the box it is not
detected correctly by my code. I know that I can
find it, but it reports checked as false all the time,
regardless of when it should report true.
i.e. in the gridviw I have:
<Columns>
<asp:BoundField DataField="EquipmentId" HeaderText="Equipment Id" />
<asp:TemplateField HeaderText="Receive">
<ItemStyle HorizontalAlign="Center" Font-Bold="True" Font-Names="Arial
Unicode MS" Font-Size="X-Small" VerticalAlign="Middle" />
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<HeaderStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="X-Small" BackColor="DarkGreen" HorizontalAlign="Left"
VerticalAlign="Middle" Width="40px" Wrap="False" />
</asp:TemplateField>
</Columns>
And my code behind
Dim chk As CheckBox
For Each rowItem As GridViewRow In GV_RecEquip.Rows
chk = CType(rowItem.Cells(0).FindControl("chkSelect"), CheckBox)
If chk.Checked = True Then
'do something
end if
End If
Next
Can someone help? Thanks!
I have a page that inherits from a master page and it contains a gridview
with a checkbox as a field.
My problem is that when I check the box it is not
detected correctly by my code. I know that I can
find it, but it reports checked as false all the time,
regardless of when it should report true.
i.e. in the gridviw I have:
<Columns>
<asp:BoundField DataField="EquipmentId" HeaderText="Equipment Id" />
<asp:TemplateField HeaderText="Receive">
<ItemStyle HorizontalAlign="Center" Font-Bold="True" Font-Names="Arial
Unicode MS" Font-Size="X-Small" VerticalAlign="Middle" />
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
<HeaderStyle Font-Bold="True" Font-Names="Arial Unicode MS"
Font-Size="X-Small" BackColor="DarkGreen" HorizontalAlign="Left"
VerticalAlign="Middle" Width="40px" Wrap="False" />
</asp:TemplateField>
</Columns>
And my code behind
Dim chk As CheckBox
For Each rowItem As GridViewRow In GV_RecEquip.Rows
chk = CType(rowItem.Cells(0).FindControl("chkSelect"), CheckBox)
If chk.Checked = True Then
'do something
end if
End If
Next
Can someone help? Thanks!