Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
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
Old June 2nd, 2010, 11:19 AM
Authorized User
Join Date: May 2007
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
Default concat string with container.databind value

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

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?
Old June 2nd, 2010, 12:25 PM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

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 Spaanjaars
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..

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

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