I have a datagrid, and am having trouble when the value is NULL.
When I run the page I get:
Operator is not valid for type 'DBNull' and string "F".
When the code hit's a value of NULL in the database, the error occurs. If the value in the table is "F", then I get "Funded"...which is correct.
I've tried several things to handle the NULL value, but can't get around the error.
Here's the HTML:
<asp:Templatecolumn HeaderText="Status">
<ItemTemplate>
<%# DisplayStatus(DataBinder.Eval(Container.DataItem, "WkPkgStatus"))%>
</ItemTemplate>
</asp:Templatecolumn>
Here's the code behind:
Function DisplayStatus(ByVal WkPkgStatus As Object) As String
Select Case WkPkgStatus
Case "F"
Return "Funded"
Case "U"
Return "UnFunded"
Case "R"
Return "RollUp"
Case IsDBNull(WkPkgStatus.Value)
Return "Not Set"
Case Else
Return "Not Set"
End Select
End Function
Thanks!
When I run the page I get:
Operator is not valid for type 'DBNull' and string "F".
When the code hit's a value of NULL in the database, the error occurs. If the value in the table is "F", then I get "Funded"...which is correct.
I've tried several things to handle the NULL value, but can't get around the error.
Here's the HTML:
<asp:Templatecolumn HeaderText="Status">
<ItemTemplate>
<%# DisplayStatus(DataBinder.Eval(Container.DataItem, "WkPkgStatus"))%>
</ItemTemplate>
</asp:Templatecolumn>
Here's the code behind:
Function DisplayStatus(ByVal WkPkgStatus As Object) As String
Select Case WkPkgStatus
Case "F"
Return "Funded"
Case "U"
Return "UnFunded"
Case "R"
Return "RollUp"
Case IsDBNull(WkPkgStatus.Value)
Return "Not Set"
Case Else
Return "Not Set"
End Select
End Function
Thanks!