I 'm calling this function below in a GridView but getting the error Conversion from type 'DBNull' to type 'String' is not valid.
I thought I was handling this properly with the line sText.Equals(DBNull.Value) but it still errors out when the comments field is null in the database. Thanks
<asp:TemplateField HeaderText="Comments">
<ItemTemplate>
<%# FormatParagraph.FormatParagraphHTML(Eval("Comments"))%>
</ItemTemplate>
</asp:TemplateField>
Public Shared Function FormatParagraphHTML(sText As String) As String
Dim strReturn As String = String.Empty
Try
If sText = String.Empty OrElse sText.Equals(DBNull.Value) Then
Return ""
Else
strReturn = Replace(sText, vbCrLf & vbCrLf, "<P>")
strReturn = ...
Go to the complete details ...