更新时间:2022-12-05 23:18:40
您可以尝试执行以下操作:
You could try something like this:
<asp:Image ID="Image1" Width="75%" Height="75%" runat="server" ImageUrl=''<%# (Eval("Photo") ?? "path/to/default/image.jpg") %>'' />
希望对您有所帮助.
Hope it helps.
您可以将其用作
You can use it as
<asp:Image ID="Image1" Width="75%" Height="75%" runat="server" ImageUrl=''<%# SetPhoto(Eval("Photo")) %>'' />
public string SetPhoto(string actualUrl)
{
if(actualUrl != "")
return actualUrl;
else
return @"~/Images/defaul.png";
}
找到要显示的默认图像,将其放置在您的网站目录下,假设您的默认图像名称为default.jpg
,现在在您的页面下方使用此代码
find a default image you want to show, place it under your web site roor, lets say your default image name isdefault.jpg
, now use this code below in your page
<asp:Image ID="Image1" Width="75%" Height="75%" runat="server" ImageUrl=''<%# (String.IsNullOrEmpty(Eval("Photo").ToString()) ? Eval("Photo"):"~/default.jpg") %>'' />
就是这样.
Thats it..