问题描述
<divalign="center"><asp:DataListID="MainAlbum"runat="server"BackColor="#CCCCCC"BorderColor="#999999"BorderStyle="Solid"BorderWidth="3px"CellPadding="4"CellSpacing="2"ForeColor="Black"GridLines="Both"RepeatColumns="4"RepeatDirection="Horizontal"><FooterStyleBackColor="#CCCCCC"/><SelectedItemStyleBackColor="#000099"Font-Bold="True"ForeColor="White"/><ItemStyleBackColor="White"/><HeaderStyleBackColor="Black"Font-Bold="True"ForeColor="White"/><ItemTemplate><div><ahref='<%#"picture/"+Eval("Name")%>'target="_blank"/><asp:ImageID="Image1"runat="server"width="200"Height="160"ImageUrl='<%#"picture/"+Eval("Name")%>'/></div></ItemTemplate></asp:DataList></div>我把图片放在pircture这个文件夹里面,想读到datalist上显示..为什么显示不出来请高手帮忙解答...
解决方案
解决方案二:
<ItemTemplate><asp:ImageID="x"runat="server"/></ItemTemplate>protectedvoidDataList1_ItemDataBound(objectsender,DataListItemEventArgse){if(e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.Item){Imagem=e.Item.FindControl("x")asImage;}}或ImageUrl='<%#GetTopPic(Eval("Id"))%>'publicstringGetTopPic(objecto){img.ImageUrl="images/top"+o+".gif";returnimg.ToString();}或<ItemTemplate><imgsrc="<%=Page.ResolveUrl("~/")%>picture/<%#Eval("字段名")%>.gif"/></ItemTemplate>
解决方案三:
<asp:ImageID="Image1"runat="server"width="200"Height="160"ImageUrl='<%#"~/picture/"+Eval("Name")%>'/></div>
解决方案四:
该回复于2011-12-26 09:19:25被版主删除