Solved

Appending Query String Value to URL in Gridview HyperlinK Field

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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 …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

726 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