I have a Gridview that pulls data from MySQL and then displays it along side a column of checkboxes that are created via a ItemTemplage in the html. this works wonderfully for creating it but problem lies in checking the status of these check boxes.
I first tried just using the checkbox.checked = true or false method but because its created dynamically the VB code doesn't see it.
I thought I had figured it out at one pont with the EnabledViewState in the VB code where it checked - if CheckBox IsNot Nothing And CheckBox.EnableViewState = True Then bla bla bla but all that was checking was to see if view state was enabled and it was which would then select all of the items and run the code under the if statment up until the checkbox was ticked. so it was updating all sql entries above the correct one as well.
What I need it to check is still If CheckBox IsNot Nothing And CheckBox.Checked = True Then
but it constantly returns false.
I thought I had found somewhat of an answer with
and other than nameing things a bit differently it may as well have been a direct copy and paste of the code but this too failed. I tried using the CheckChanged and the OnCheckChaned properties but VS didnt recognize them as valid properties of the command,
I thouht there may be someway to use the attributes property and played around with variations of CheckBox.Attributes(ViewSt
d)) and Im still not convinced Im 100% wrong with going this direction, I just couldnt figure out the exact wording on it.
In any event, Im back here begging for help
' VB.NET Code
Dim tr As TableRow
Dim RowCounter As Integer = 0
For Each tr In GridViewID.Rows
Dim cb As CheckBox = GridViewID.Rows(RowCounter).Cells(0).FindControl("CheckBoxID")
If cb IsNot Nothing And cb.Checked = True Then
'Code to pull data from GridViewID and compare to DB
'Code to Update MySQL Database
RowCounter = +1
<!--ASP / HTML CODE-->
<asp:GridView ID="GridViewID" runat="server">
<asp:TemplateField HeaderText="CheckBox Column">
<asp:CheckBox runat="server" ID="CheckBoxID" Checked="false" EnableViewState="true" />