Solved

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

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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