Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 2nd, 2010, 11:19 AM
Authorized User
Points: 395, Level: 6
Points: 395, Level: 6 Points: 395, Level: 6 Points: 395, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: London, , United Kingdom.
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
Default concat string with container.databind value

Hi
I am using a repeater control that is bind with a data reader.
In <itemtemplate> i am trying to create a hyperlink that would be something like ....


<a href="~\Nominations\votes.aspx?ContestantID=" & <%# DataBinder.Eval(Container.DataItem,"ContestantID") %> >fsdfsf

</a>
but for some reason its not rendering the actuall value seems like some thing wrong with the concatination i am doing ...


Can any one help me on this?
__________________
Cheers
Sheraz
Reply With Quote
  #2 (permalink)  
Old June 2nd, 2010, 12:25 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You need to make the constant part of the URL a part of the databinding expression. E.g.:

<a href='<%# @"~\Nominations\votes.aspx?ContestantID=" + DataBinder.Eval(Container.DataItem,"ContestantID") %>' runat="server">fsdfsf</a>

Rather than using double quotes you need single quotes for the href attribute. And, in order to successfully use the ~ in the address, you need runat="server" on the control as well.

The @ is needed in C# to escape the slashes in your URL. However, since these are likely web URLs, this is probably better:

<a href='<%# "~/Nominations/votes.aspx?ContestantID=" + DataBinder.Eval(Container.DataItem,"ContestantID") %>' runat="server">fsdfsf</a>

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!

Last edited by Imar; June 2nd, 2010 at 12:29 PM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do Very Large String Concat? EcceBozo XSLT 2 July 29th, 2008 03:58 PM
String.Concat NOT same as '&" Ron Howerton Visual Basic 2005 Basics 0 November 21st, 2006 04:34 PM
Mailto string and concat paul20091968 Access VBA 1 August 10th, 2006 12:40 PM
Strange string concat edislasm Javascript How-To 2 September 6th, 2005 02:17 AM
concat problems gonesail XSLT 1 May 12th, 2004 08:19 PM



All times are GMT -4. The time now is 04:53 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.