<asp:Image ID="Image2" runat="server" 
         ImageUrl='~\\Images\\thumbnail\\<%# Eval("brand")%>\\<%# Eval("thumbnail")%>' />

I tried several times with different types and didn't succeed.I want to bind two data from sqlserver database and put them in Image URL continuously.
Which the brand is something like "Dell" and thumbnail is "123.jpg"

What is the correct form ?

Please help me If you can, this is so crucial for me.

Recommended Answers

All 7 Replies

Is that the inside repeater or so?

If you mean whether the code is in something like dataList, the answer is yes.
And also in Item Templates.

Use Eval format option.

...  ImageUrl='<%# Eval("T1","~\\imgs\\{0}") %>' ..

That's right but you suppose you have two parameter e.g T1 and T2.
Then can I use it like this ? :

<%# Eval("T1","T2","~\\Images\\{0}\\{1}")%>

my friend single / will do your job correctly...

ImageUrl='~\Images\thumbnail\<%# Eval("brand")%>\<%# Eval("thumbnail")%>'

Enjoy...mark the post resolved if it helps..

I think I would try

<asp:Image ID="Image2" runat="server" 
         ImageUrl='~\\Images\\thumbnail\\<%# Eval("brand") + "\\" + Eval("thumbnail")%>' />

, or something in that nature...

No that's not working,but I found the working code :

<%# String.Format("~\\Images\\thumbnail\\{0}\\{1}", Eval("brand"), Eval("thumbnail")) %>

Anyway thank you all for help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.