I am working with an old web application developed in VB.NET 1.1 framework. I am having an issue with checkboxes.
I have the following code for my checkbox:
<asp:TemplateColumn HeaderText="Reviewed">
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemTemplate>
<asp:checkbox ID="chkAppRev" Runat="server"
OnCheckedChanged="onCheckChange" AutoPostBack="True" />
</ItemTemplate>
</asp:TemplateColumn>
and this for my OnCheckChanged
event:
Public Sub onCheckChange(ByVal sender As Object, ByVal e As EventArgs)
Dim strSQL As String = String.Empty
Dim inbox As CheckBox = CType(sender, CheckBox)
Dim dgItem As DataGridItem = CType(inbox.NamingContainer, DataGridItem)
Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection(ConfigurationSettings.AppSettings("CONNECTIONSTRING"))
Try
'--update checkbox field on record in database
conn.Open()
If inbox.Checked = True Then
strSQL = "Update AppUserJobs Set AppChecked=1 " & _
"Where AppUserId=" & Convert.ToInt32(dgItem.Cells(9).Text) &
" and JobId=" & Convert.ToInt32(dgItem.Cells(10).Text)
Else
strSQL = "Update AppUser Set AppChecked=0 " & _
"Where AppUserId=" & Convert.ToInt32(dgItem.Cells(9).Text) &
" and JobId=" & Convert.ToInt32(dgItem.Cells(10).Text)
End If
Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(strSQL, conn)
Dim intRec As Integer = cmd.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
Finally
If (conn.State = ConnectionState.Open) Then
conn.Close()
End If
End Try
BindData()
End Sub
This all works fine until I add another check box in the asp code and another oncheckchanged
method, it seems like it just skips over the query.
Does anyone have any ideas what I missed?