当数据库在该列中没有值时显示默认照片 [英] show default photo when database has no value in that column

查看:64
本文介绍了当数据库在该列中没有值时显示默认照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,问题是我想在各行没有记录时显示默认图片。

请告诉我。谢谢你。



 <   asp:TemplateField     HeaderText   = 博士照片 >  
< ItemTemplate >
< asp:Image ID = Image1 runat = server 样式 = 身高:80px; width:100px; ImageUrl =' <% String .Format( 〜/ Upload / Docters / + Eval( ImgName))%> ' / >
< / ItemTemplate >
< / asp:TemplateField >

解决方案

尝试使用:

< ; asp:image id =   Image1 runat =    server style =   height:80px ; width:100px; imageurl =  <%#string.IsNullOrEmpty(Eval( ImgName  ))? 〜/ images / default.png  :String.Format(〜/ Upload / Docters /   + Eval( ImgName  ))%> /> 



希望它会有所帮助!!


hello friends, problem is i want to show default image when the respective row don't have record.
please tell me. Thanks in adv.

<asp:TemplateField HeaderText="Dr. Photo">
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" Style="height: 80px; width: 100px;" ImageUrl='<%# String.Format("~/Upload/Docters/" + Eval("ImgName")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>

解决方案

Try using this:

<asp:image id="Image1" runat="server" style="height: 80px; width: 100px;" imageurl="<%# string.IsNullOrEmpty(Eval("ImgName")) ? "~/images/default.png" : String.Format("~/Upload/Docters/" + Eval("ImgName")) %>" />


Hope it will be helpful !!


这篇关于当数据库在该列中没有值时显示默认照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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