如果数据库不等于null,则添加图像 [英] add image if data base not equal null

查看:102
本文介绍了如果数据库不等于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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆