467,227 Members | 1,406 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,227 developers. It's quick & easy.

Combine variable and #bind

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
Jun 21 '07 #1
  • viewed: 2139
Share:
1 Reply
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
--
Milosz
"David C" wrote:
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
Jun 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tao | last post: by
3 posts views Thread by Dabbler | last post: by
2 posts views Thread by DanWeaver | last post: by
37 posts views Thread by minkoo.seo@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.