Print Page | Close Window

Using asp:HyperLinkColumn Pass DB Value

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=3160
Printed Date: 28 March 2026 at 4:29pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Using asp:HyperLinkColumn Pass DB Value
Posted By: BigMeat
Subject: Using asp:HyperLinkColumn Pass DB Value
Date Posted: 31 May 2003 at 1:08am
Hi

I am pretty new to asp.net and have started building my first app.  OK so I have a dataset which I populate as below.  I then put the results in a datagrid.  I then want to use a an asp:HyperLinkColumn which shows SvcDesc but has a value of SvcID.  When the user click this link the selected rows SvcID is sent to another page via a querystring.  However im unsure how to include the SvcID into the DataNavigateUrlFormatString.

I had a an attempt by doing something like but didnt work

DataNavigateUrlFormatString="details.aspx?SvcID=<%#SvcID%>"

But did not work

Dim Conn As New SqlConnection(ConfigurationSettings.AppSettings("connBSS"))
Conn.Open()
Dim strSQL As String = "SELECT SvcDesc, SvcID, FROM ServiceProviderServices"
Dim objAdapter As New SqlDataAdapter(strSQL, Conn)
objAdapter.Fill(dsResults, "Results")
Dim objDataView As New DataView(dsResults.Tables("Results"))
dgResults.DataSource = dsResults
dgResults.DataBind()

Many thanks in advance




Replies:
Posted By: MorningZ
Date Posted: 31 May 2003 at 7:59am

why are you throwing that into a datagrid??

it'll be easier just to make your own table/display using a asp:repeater, and then you could super easily build a link



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: otaku
Date Posted: 01 June 2003 at 5:35pm

Hey,

this will work using asp:HyperLinkColumn with your datagrid:

<asp:DataGrid
id="dgResults"
AutoGenerateColumns="false"
runat="server">
<Columns>
<asp:HyperLinkColumn
HeaderText="Header Text Here"
DataNavigateUrlField="SvcID"
DataNavigateUrlFormatString="details.aspx?SvcID={0}"
DataTextField="SvcDesc"
/>
<asp:BoundColumn
HeaderText="AnotherField Text Header"
DataField="AnotherField"
/>
</Columns>
</asp:DataGrid>



-------------
Martial Boissonneault
http://getElementById.com/


Posted By: MorningZ
Date Posted: 02 June 2003 at 8:46am

how does the grid know what to fill {0} with?
(kinda new at Datagrid myself)

btw Marital, kick ass website you run.. its saved me on more than one occasions over the past 18 months :-)



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: otaku
Date Posted: 02 June 2003 at 9:31am

Hello MorningZ,

That {0} specifie the parameter index in a zero-based list of parameters.
This value can only be set to 0 because there is only one value in each cell.

Thanks for the kind words about getElementById.com. Glad to know my website help.



-------------
Martial Boissonneault
http://getElementById.com/



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net