Combine variable and #bind

D

David C

I have a DataList that displays photos and is bound to a list of files. Is
there a way to combine the value of a variable (strpath) with the #
Bind(...) in the ImageURL field. Below is what I have now.

<asp:ImageButton ID="ImgBtn1" runat="server"

CausesValidation="false" CommandName="Select"

AlternateText='<%# Bind("Name") %>'

ImageUrl='<%# Bind("FullName") %>'

CommandArgument='<%# Bind("FullName") %>'

OnClientClick="return showpic(this);"

OnCommand="ImgBtn1_Command" Height="100" Width="150" />

I would like to add the value of strpath to the # Bind("FullName").
Thanks.

David
 
G

Guest

Good morning David,

Yes there is. You just need to expose strpath as page class property (or
simply as protected variable)

-- aspx page code --

<asp:ImageButton ID="ImgBtn1" runat="server"
CausesValidation="false" CommandName="Select"
AlternateText='<%# Eval("Name") %>'
ImageUrl='<%# Eval("FullName") %>'
CommandArgument='<%# ImageDirPath + Bind("FullName") %>'
OnClientClick="return showpic(this);"
OnCommand="ImgBtn1_Command" Height="100" Width="150" />

-- end aspx page code --



-- code behind/beside

protected string ImageDirPath
{
get
{
return "~/Images/";
}
}

-- end code behind/beside

Note I used Eval() instead of Bind() because (in this case) you're not
getting the value back from the control.

hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top