ASP.NET: Checkbox Multirow deletion

liunx

Guest
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>Because the dataGrid does not support event bubbling to controls unless there is an item selected...


You have to use DataList for that.i'm not sure what you mean.

like i said i have an exact replica of this fully functional - and it uses a datagrid. the only difference there is it goes through and for each checked it appends the value to a string, instead of performing a function.

and i can tell you that works, heck i'll send you the code and you can fill it with test values to see if you like.

anyway i guess i'll just look closer at it and see how it differs from my other one..

EDIT: Well one of the differences is that in the working one, after it appends to a string it hides the current panel and shows another one... whereas in this case it just keeps the panel. Could it be that since the Checks are not posted back, when the page is posted back the values it sees are the 'newest' in that they are now unchecked again? I don't understand why that would happen though.. since (in the working one) it stored the values first, THEN hid the panels. Bah, i'm at a loss.That is an odd method of handling it. Why hide the panel at all, it should be visible to uncheck before they decide to submit.the hiding of panels is just mirroring submitting to another form of old ASP

after they made some selections and hit submit, it would hide the panel and show you your selections so you can confirm in a new panel

hiding/showing panels is a good method in place of submitting between pages

anyway in this case that is not necessary as after a record is deleted i just want to see the updated resultsokay i figured out what i was doing wrong

i put the code to refill the datagrid in Pageload instead of after the Delete function completes. anyway it works now, thanks as always afterburn =)yep that would do it also ...
 
Back
Top