Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now