如何在数据列表控件中显示图像 [英] how display image in datalist control

查看:102
本文介绍了如何在数据列表控件中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:DataList ID="DataList1" runat="server">
     <ItemTemplate>
         <asp:Image  ImageUrl='<%#DataBinder.Eval("imager")  %>' ID="Image1" runat="server" />
 </ItemTemplate>
    </asp:DataList>



我尝试使用上面的代码来显示图像,但不起作用
帮助我



I try above code to display image but not working
help me

推荐答案

在使用DataBinder.Eval(object,String)时缺少一些东西,您需要知道它至少需要两个参数,一个是Object,另一个是字符串值.您可以从那里-[Web表单页面的数据绑定表达式] [ ^ ]了解如何使用Databinder.Eval绑定数据[ Ex Image]
You are some thing missing while using DataBinder.Eval(object,String) you need to know it requires minimum two parameter one is Object and other is string value. you can know more about it from there-[Data Binding Expressions for Web Forms Pages][^] to know how to use Databinder.Eval to bind data [Ex Image]
<asp:image imageurl="<%#DataBinder.Eval(Container.DataItem,"imager")  %>" id="Image1" runat="server" xmlns:asp="#unknown" />




or

<asp:Image id="myImage" runat="server"
   ImageUrl=''<%# DataBinder.Eval ( Container, "DataItem.ProductImage",
      "~/shared/images/{0}" ) %>''>


这将帮助您
在ASP.NET中进行图像处理 [
This will help you
Image Handling In ASP.NET[^]


ImageUrl必须指向您的图像虚拟路径. DataBinder.Eval("imager")的值是什么?您是否需要添加路径?
ImageUrl must be pointing at your image virtual path. What is the value of DataBinder.Eval("imager")? Do you need to append a path perhaps?


这篇关于如何在数据列表控件中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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