eRad
12-03-2004, 11:51 AM
i have a datagrid with checkboxes placed on each row. upon clicking a button i loop through each item in the datagrid, check if the checkbox is selected, and if it is i execute a function.
i have this working perfectly on another slightly different application, however for this one the Checked property always seems to be false, regardless of what i do. I know all the casting and SQL is correct since i tried test values in access, and i changed the if to Not and it showed all the records. why would the Checked event not trigger? i have literally the exact same code working in another app, and i can't seem to figure out what's different here.
any ideas?
Sub Delete_Requests (sender As Object, e As System.EventArgs)
Dim DemoGridItem As DataGridItem
For Each DemoGridItem In matrix.Items
Dim myCheckbox As CheckBox = CType(DemoGridItem.Cells(0).Controls(1), CheckBox)
If myCheckbox.Checked Then
test.Text=DemoGridItem.Cells(1).Text
Delete_Record(DemoGridItem.Cells(1).Text)
End If
Next
End Sub
<asp:dataGrid id="matrix" runat="server">
<HeaderStyle></HeaderStyle>
<FooterStyle></FooterStyle>
<Columns>
<asp:TemplateColumn>
<itemtemplate>
<asp:CheckBox id="chkSelect" runat="server"></asp:CheckBox>
</itemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:dataGrid>
i have this working perfectly on another slightly different application, however for this one the Checked property always seems to be false, regardless of what i do. I know all the casting and SQL is correct since i tried test values in access, and i changed the if to Not and it showed all the records. why would the Checked event not trigger? i have literally the exact same code working in another app, and i can't seem to figure out what's different here.
any ideas?
Sub Delete_Requests (sender As Object, e As System.EventArgs)
Dim DemoGridItem As DataGridItem
For Each DemoGridItem In matrix.Items
Dim myCheckbox As CheckBox = CType(DemoGridItem.Cells(0).Controls(1), CheckBox)
If myCheckbox.Checked Then
test.Text=DemoGridItem.Cells(1).Text
Delete_Record(DemoGridItem.Cells(1).Text)
End If
Next
End Sub
<asp:dataGrid id="matrix" runat="server">
<HeaderStyle></HeaderStyle>
<FooterStyle></FooterStyle>
<Columns>
<asp:TemplateColumn>
<itemtemplate>
<asp:CheckBox id="chkSelect" runat="server"></asp:CheckBox>
</itemtemplate>
</asp:TemplateColumn>
</Columns>
</asp:dataGrid>