Server Error in '/' Application.

Operator '=' is not defined for type 'DBNull' and string "M".

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 defined for type 'DBNull' and string "M".

Source Error:


Line 250:
Line 251:                End If
Line 252:                If DtCandidates.Rows(i).Item("gender") = "M" Then
Line 253:                    candidatemalepartycount += 1
Line 254:                Else

Source File: C:\inetpub\vhosts\beta.sxmelections.com\partycandidates.aspx.vb    Line: 252

Stack Trace:


[InvalidCastException: Operator '=' is not defined for type 'DBNull' and string "M".]
   Microsoft.VisualBasic.CompilerServices.Operators.ConditionalCompareObjectEqual(Object Left, Object Right, Boolean TextCompare) +1260103
   partycandidates.party_Load(Object sender, EventArgs e) in C:\inetpub\vhosts\beta.sxmelections.com\partycandidates.aspx.vb:252
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3770.0