我们可以有这样的图片网址吗 [英] Can we have imageurl like this

查看:79
本文介绍了我们可以有这样的图片网址吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我想在gridview中的imagebutton的imageurl中具有评估功能.
但这会带来编译时间.我们可以这样吗?如果是的话,语法是什么?

Hi All

I want to have eval funtionality in imageurl of imagebutton which is in gridview.
But it throws compile time. Can we have like this.If so what is the syntax?

<asp:ImageButton ID="imgActivate" runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem, "picturename")?"/Images/Active.PNG":"/Images/InActive.PNG" %>'

                                            OnClick="imgActivate_Click"  OnCommand="imgActivate_Command" CommandArgument='<%# Eval("UserId") %>'

                                            CommandName="Activate"  />



问候
froxy



Regards
froxy

推荐答案

不,这不起作用.服务器标记中不能包含代码块.
No, this wont work. You cant have code blocks in server tags.


http://www.beansoftware.com/ASP.NET-Tutorials/Conditional-Values-Styles-GridView.aspx[^]

But you should better get the URL in code behind.


您可以按照以下方式进行操作.
hi you can do that in the Following Way.
<asp:TemplateField HeaderText="Small Image">
                                       <ItemTemplate>
                                           <asp:Image ID="imgPlacesSmallImage" ImageUrl='<%# String.Concat(@"~\Uploads\PlaceImages\SmallImage\",Eval("placetovisitimages_image")) %>' AlternateText="N.A"

                                               Width="25%" Height="15%" runat="server" />
                                       </ItemTemplate>
                                       <ItemStyle Width="30%" HorizontalAlign="Center" />
                                   </asp:TemplateField>


这篇关于我们可以有这样的图片网址吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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