日期:2014-05-19  浏览次数:20828 次

使用DataList绑定从数据库提取的图片Url出错
<asp:datalist   id= "dl1 "   runat= "server "   Width= "527px "   Height= "192px "   GridLines= "Both "   ShowHeader= "False "   RepeatDirection= "Horizontal "   BorderWidth= "1px "   BorderColor= "Black "   ShowFooter= "False ">
<SelectedItemTemplate>
<FONT   face= "宋体 "> </FONT>
</SelectedItemTemplate>
<ItemTemplate>
<asp:Image   id= "Image1 "   Runat= "server "   Width= "115 "   Height= "100 "   ImageUrl= "Admin/ <%#   DataBinder.Eval(Container.DataItem, "img ")   %> "> (就是这里,运行后图片显示不出来,如果把
<%#   DataBinder.Eval(Container.DataItem, "img ")   %> 加上引号或者双引号,又会说打不开设计视图),我看了下生成的源文件,这里的代码是
<img   id= "dl1__ctl0_Image1 "   src= "Admin/ <%#   DataBinder.Eval(Container.DataItem,&quot;img&quot;)   %> "   border= "0 "   style= "height:100px;width:115px; "   />
也就是说绑定语句根本没有编译,请问怎么解决
</asp:Image> <BR>
<asp:HyperLink   id= "hl1 "   Runat= "server "   NavigateUrl= "Admin/addArticle.aspx ">
<%#   DataBinder.Eval(Container.DataItem, "title ")   %>
</asp:HyperLink>
</ItemTemplate>
</asp:datalist>

------解决方案--------------------
<asp:Image id= "Image1 " Runat= "server " Width= "115 " Height= "100 "
ImageUrl= ' <%# "Admin/ " + DataBinder.Eval(Container.DataItem, "img ") %> ' />
------解决方案--------------------
try

ImageUrl= " ">

imageurl= ' <%# "Admin/ " & DataBinder.Eval(Container.DataItem, "img ") %> '