打算在datalist的相应位置显示图片,详细如下:图片是事先的提交页面提交进程序文件夹中的“upload”文件夹里
“upload”文件夹里保存图片
相应的在数据库表中的photo字段保存图片的名称,比如20050823.jpg 以下是Databind函数,从nobel表中取一些字段,其中包括图片名photo字段
SqlDataAdapter myDataAdapter=new SqlDataAdapter("SELECT * from nobel order by times desc",myConnection); 
DataSet myDataSet=new DataSet();
myDataAdapter.Fill(myDataSet,"nobel");
myDataList.DataSource=myDataSet.Tables["nobel"].DefaultView;现在想把图片放在某位置,“ImageUrl”该如何写?
下面的是我尝试的,不正确
<td width="30%" rowspan="4"><asp:HyperLink id="photo" runat="server" NavigateUrl="#" ImageUrl="upload\"+"<%#DataBinder.Eval(Container.DataItem,"photo")%>">HyperLink</asp:HyperLink></td>

解决方案 »

  1.   

    图片可以这样来装载<asp:TemplateColumn>
    <HeaderTemplate>
    Product Image
    </HeaderTemplate>
    <ItemTemplate>
    <asp:Image id=ImgProduct runat="server" Width="100px" Height="80px" imageurl='<%# Databinder.Eval(Container.DataItem,"ImagePath","{0}") %>' >
    </asp:Image>
    </ItemTemplate>
    </asp:TemplateColumn>
      

  2.   

    to:flashasp(flashasp)
    我的photo字段保存的是图片的名称,而非路径
     路径还有“upload”
      

  3.   

    <td width="30%" rowspan="4"><asp:HyperLink id="photo" runat="server" NavigateUrl="#" ImageUrl='<% "upload/"+#DataBinder.Eval(Container.DataItem,"photo")%>'>HyperLink</asp:HyperLink></td>
      

  4.   

    将imageurl='<%# Databinder.Eval(Container.DataItem,"ImagePath","{0}") %>' 换成你的图片名称更简单吗??就象楼上这样