Greetings,
I've been unable to determine which CheckBoxes are being 'checked' within a DataGrid. The following code iterates through the entire datagrid, but never identifies the checked checkboxes.
Here is the datagrid I'm using as well as the button to kick things off.
Clearly I'm missing something, but obviously I'm not bright enough to figure it out.
I greatly appreciate any help you can provide.
thanks
I've been unable to determine which CheckBoxes are being 'checked' within a DataGrid. The following code iterates through the entire datagrid, but never identifies the checked checkboxes.
Code:
Sub OnCheckOut( s As Object, e As EventArgs )
Dim i As Integer
Dim blnIsChecked As Boolean
For i = 0 to dgrd_EmailUpdate.Items.Count - 1
blnIsChecked = DirectCast(dgrd_EmailUpdate.Items(i).Cells(4).FindControl("chkSelected"), Web.UI.WebControls.CheckBox).Checked
If blnIsChecked = True Then
response.write( i & " IS Checked <BR>")
response.write("<BR>")
Else
response.write( i & " IsNotChecked ")
response.write("<BR>")
End If
Next
End Sub
Here is the datagrid I'm using as well as the button to kick things off.
Code:
<asp:DataGrid ID="dgrd_EmailUpdate"
AutoGenerateColumns="False" Runat="Server"> <Columns>
<asp:BoundColumn DataField="ID" HeaderText="ID" />
<asp:BoundColumn DataField="EmailAddress" HeaderText="Email Address" />
<asp:BoundColumn DataField="IPaddress" HeaderText="IPAddress" />
<asp:BoundColumn DataField="datetime" HeaderText="DateTime" HeaderStyle-Width="100" />
<asp:TemplateColumn HeaderText="Remove"
<ItemTemplate>
<TABLE>
<TR>
<TD align="center">
<asp:CheckBox id="chkSelected" runat="server" />
</TD>
</TR>
</TABLE>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
<asp:Button Text="btnRemove" style="FONT:8pt Verdana; WIDTH: 100px" OnClick="OnCheckOut" RunAt="server" />
Clearly I'm missing something, but obviously I'm not bright enough to figure it out.
I greatly appreciate any help you can provide.
thanks