i want to achievet the following Url
ImageUrl='~/products_pictures/(imageId)_middle.jpg
im using gridview and datalist
im trying the follwoing combination but it not working
<asp:Image ID="Image1" ImageUrl='~/products_pictures/<开发者_如何学C;%#Eval("Id")%>_middle.jpg' runat="server" /></td>
<asp:Image ID="Image1" ImageUrl=<%"~/products_pictures/"%><%#Eval("Id")%><%"_middle.jpg"%> runat="server" />
I would use String.Format
for this. It makes concatenation much easier:
<asp:Image ID="Image1" runat="server" ImageUrl='<%# String.Format("~/products_pictures/{0}_middle.jpg", Eval("ID"))%>'
this should work:
</td><asp:Image ID="Image1" ImageUrl="~/products_pictures/<%#Eval("Id")%>_middle.jpg" runat="server" /></td>
if not debug from this:
</td><%#Eval("Id")%></td>
ells you can try
<%# ((objectName)Container.DataItem).Id%>
((DataRowView)Container.DataItem)["Id"]
This might work
<asp:Image ID="Image1" runat="server" ImageUrl="~/products_pictures/<%#Eval("id") %>_middle.jpg"/>
If not you can put a asp:Literal
, and a HiddenField
to store id and in GridView.RowDataBound
Event you can add image as a text to the literal
The server tag is not well formed because of the quotes
put single quotes on the outside and try again
ImageUrl='~/products_pictures/<%#Eval("Id")%>_middle.jpg'
精彩评论