Solved

Appending Query String Value to URL in Gridview HyperlinK Field

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

773 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