Solved

Appending Query String Value to URL in Gridview HyperlinK Field

Posted on 2010-09-23
2
673 Views
Last Modified: 2013-11-07
Here's my issue. I'm passing a value to the page called degree IIe: page.aspx?degree=1

and I need to append it to the NavigateURL value of a hyperlink field in a Gridview.

I've thrown everything at it I can think of. Thanks in advance for your help.  
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            CellPadding="4" DataKeyNames="InterestID" DataSourceID="SqlDataSource1" 
            ForeColor="#333333" GridLines="None">
            <RowStyle BackColor="#E3EAEB" />
            <Columns>
...                <asp:HyperLinkField NavigateUrl="DegreesToInterest.aspx" 
                    Text="ManageInterests" />
            </Columns>
...
        </asp:GridView>

Open in new window

0
Comment
Question by:tcottrill
2 Comments
 
LVL 8

Expert Comment

by:Lotok
ID: 33745191
Markup

<asp:HyperLinkField NavigateUrl='<%# value() %>' Text="ManageInterests" />


Code Behind

Public Property Value() as string


Then assign the url into the value property. Hope that makes sense. :)
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 250 total points
ID: 33745676
You can do something like this where Degree is to be a field bound to your GV.

<asp:HyperLinkField Text="ManageInterests"
DataNavigateUrlFields="Degree"
       DataNavigateUrlFormatString="DegreesToInterest.aspx?degree={0}"  />

Ref: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.datanavigateurlformatstring.aspx

Note: You can also do that in Code-behind but in that case you need to use HyperLink inside a TemplateField.

Another eg.: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_24867919.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

17 Experts available now in Live!

Get 1:1 Help Now