Solved

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

Posted on 2015-01-25
2
245 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

Technology Partners: 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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

630 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