Checking whether value is DBNull

askinjust

New Member
I have the following function:\[code\]Public Shared Function imageExists(ByVal path As Object) As Boolean If IsDBNull(path) = False Or Not Nothing Then Dim pathString As String = Convert.ToString(path) If Exists(HttpContext.Current.Server.MapPath(path)) Then Return True Else Return False End If Else Return False End If End Function\[/code\]Called by the visible property for this image control:\[code\]<asp:Image ID="img_SmallImage" runat="server" ImageUrl='<%# "~/Content/Images/Exclusive/" + Eval("trip_SmallImage") %>' Visible='<%# OnTheMain.Images.Validation.imageExists(Eval("trip_SmallImage"))%>' />\[/code\]No matter what I try for the \[code\]If IsDBNull\[/code\] part, it either ignores it and executes the code, or returns an error such as \[code\]Conversion from type 'DBNull' to type 'String' is not valid.\[/code\]How can I rectify the situation?
 
Back
Top