bang head here
Member
Pretty easy, Im reading in a table that has some Null values scattered about. In binding the data to the grid I have an error because of the Nulls, cannot Cast Null value into a String. Yeah well that makes sense. But how can I call a function to check for the Null value and then populate the cell with " "?
&
The above wont work because the Parameter for TrimNull is Null so I get the same error right? How can I do a logic check like this for DBNulls?
Many thanks.
Code:
<asp:Label ID="lblDateOut" Text=<%# TrimNull(Mid(DataBinder.Eval(Container.DataItem, "Date Out"),1,10)) %> Runat="server" EnableViewState="false" />
Code:
Public Function TrimNull(ByVal sInput As String)
If (sInput is System.DBNull.Value) Then
TrimNull = " "
return TrimNull
Else
TrimNull = sInput
return TrimNull
End If
End Function
Many thanks.