Solved

Appending Query String Value to URL in Gridview HyperlinK Field

Posted on 2010-09-23
2
670 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
asp.net mvc5 3 37
Check if number is currency 15 29
Setting runtime form location 4 18
Different Delete Messages 7 12
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

14 Experts available now in Live!

Get 1:1 Help Now