Solved

Include value of databinder in request querystring in asp.net project

Posted on 2015-01-25
2
229 Views
Last Modified: 2015-01-26
I am trying to include the value returned by the databinder value in the navigate URL of a hyperlink

I am trying to use the following but keep getting errors

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/viewer.aspx?Rec_ID=<%# DataBinder.Eval(Container.DataItem, "Rec_ID")%>">"Read More</asp:HyperLink>

I'm not sure what I am missing but would appreciate any help anybody can give.  I keep getting a 'server tag not well formed' error.
0
Comment
Question by:Mike_Stevens
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 40569907
Use it like this:
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "Rec_ID", "~/viewer.aspx?Rec_ID={0}")%>'>Read More</asp:HyperLink>

Open in new window

This is one of very few situations where you cannot use double quotes for an attribute. Furthermore, you cannot mix literals and server side code as usual, you need to supply the attribute value as one call, using the formatting argument as I showed above. See for more information: https://msdn.microsoft.com/en-us/library/2d76z3ck%28v=vs.110%29.aspx
0
 

Author Comment

by:Mike_Stevens
ID: 40570391
That is what I needed.  Thank you so much,
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to filter by key press ? 6 55
ASP.net Markup for Sub Menu 2 40
Installing .NET 3.5 on Windows Server 2012 1 58
asp.net, radiobuttonlist, c# 2 26
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question