Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2015-01-25
2
Medium Priority
?
248 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 2000 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

715 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