我有以下功能:
Public Shared Function imageExists(ByVal path As Object) As Boolean
If IsDBNull(path) = False Or Not path Is 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
由此图像控件的可见属性调用:
<asp:Image ID="img_SmallImage" runat="server" ImageUrl='<%# "~/Content/Images/Exclusive/" + Eval("trip_SmallImage") %>' Visible='<%# OnTheMain.Images.Validation.imageExists(Eval("trip_SmallImage"))%>' />
无论我为该If IsDBNull
部分尝试什么,它要么忽略它并执行代码,要么返回错误,例如Conversion from type 'DBNull' to type 'String' is not valid.
我该如何纠正这种情况?