私は次の機能を持っています:
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
このイメージ コントロールの visible プロパティによって呼び出されます。
<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.
どうすれば状況を修正できますか?