andycharger
Centurion
- Joined
- Apr 2, 2003
- Messages
- 152
I have a checkbox on my screen that I need to Check or uncheck depending on what the database says.
So during my page load, im querying the database and pulling back the record i need.
I then check the data using an if statement that works. However, when it tries to set my Checkbox to the right condition, the page falls over. Can someone help me and tell me what im doing wrong?
Here is my code:
At the top of the Code page I have this:
My code does the following.
The aspx code on the page is as follows:
can anyone help me?
So during my page load, im querying the database and pulling back the record i need.
I then check the data using an if statement that works. However, when it tries to set my Checkbox to the right condition, the page falls over. Can someone help me and tell me what im doing wrong?
Here is my code:
At the top of the Code page I have this:
Code:
Protected WithEvents chkOMB As System.Web.UI.WebControls.CheckBox
My code does the following.
Code:
Dim strUser As String
Dim Choices As String
Dim oConn As SqlConnection
Dim oComm As SqlCommand
Dim strUserPerson As String
Dim oReader As SqlDataReader
Dim sSQL As String
Dim sConn As String
sSQL = "SELECT * FROM complaints where complaint_id = " & Request.QueryString("complaint_id") & ""
sConn = ConfigurationSettings.AppSettings("ConnectionString")
oConn = New SqlConnection(sConn)
oConn.Open()
oComm = New SqlCommand(sSQL, oConn)
oReader = oComm.ExecuteReader()
While oReader.Read
If IsDBNull(oReader("ombudsman_yesno")) Then
chkOMB.Checked = False
Else
If oReader("ombudsman_yesno") = "True" Then
chkOMB.Checked = True
Else
chkOMB.Checked = False
End If
End If
End While
dgnews.DataSource = oReader
dgnews.DataBind()
oConn.Close()
The aspx code on the page is as follows:
Code:
<td class="normaltext" align="left" colspan="2"><asp:CheckBox id="chkOMB" runat="server" Enabled="true"></asp:CheckBox></td>
can anyone help me?