如果数据库不等于null,则添加图像 [英] add image if data base not equal null
问题描述
我从数据库绑定用户的图像
< asp:Image ID =post_user_imagerunat =server ImageUrl ='<%#/ photos /+ DataBinder.Eval(Container.DataItem,userphoto)%>'Width =74pxHeight =61px/>
i需要在aspx中编写代码
if((Container.DataItem,userphoto)! = null)
{
< asp:Image ID =post_user_imagerunat =serverImageUrl ='<%# /photos/\"+DataBinder.Eval(Container.DataItem,\"userphoto)%>'宽度=74px高度=61px/>
}
其他
{
// ----将出现defulte图像
}
我该怎么做
i bind the user's image from the database
<asp:Image ID="post_user_image" runat="server" ImageUrl='<%#"/photos/"+DataBinder.Eval(Container.DataItem,"userphoto") %>' Width="74px" Height="61px" />
i need to write code in aspx
if((Container.DataItem,"userphoto")!=null)
{
<asp:Image ID="post_user_image" runat="server" ImageUrl='<%#"/photos/"+DataBinder.Eval(Container.DataItem,"userphoto") %>' Width="74px" Height="61px" />
}
else
{
//---- the defulte image will appear
}
how can i do that
推荐答案
ImageUrl='<%#"/photos/"+String.IsNullOrEmpty(DataBinder.Eval(Container.DataItem,"userphoto")?"":DataBinder.Eval(Container.DataItem,"userphoto")%>'
这篇关于如果数据库不等于null,则添加图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!