Operator is not valid for type 'DBNULL' and string....
Posted on 2004-09-07
I recently altered one of my datagrids I use and added a dropdownlist, a checkbox, and another simple textbox. I setup my sql table like I always do for checkboxes and what not. For some reason when you now edit a new row that's been added to the grid I get the following error:
Operator is not valid for type 'DBNull' and string "Service".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Operator is not valid for type 'DBNull' and string "Service".
Line 206: If AddingNew = False And Not (Val Is Nothing) Then
Line 207: Select Case Val
Line 208: Case "Service"
Line 209: Return 1
Line 210: Case "Parts"
Source File: c:\inetpub\wwwroot\BadChecks\datagrid1130test.aspx Line: 208
How do I get it to recognize the empy/null sql field and move past it? The code its hanging up on is here:
Function dgDropDown1GetIDX(ByVal Val As Object) As Integer
If AddingNew = False And Not (Val Is Nothing) Then
Select Case Val
Case "New Sales"
Case "Used Sales"
Any ideas? I use this function to get the value that is already in the sql table.