By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,152 Members | 2,159 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,152 IT Pros & Developers. It's quick & easy.

Combine variable and #bind

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.