Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Using asp:HyperLinkColumn Pass DB Value
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Using asp:HyperLinkColumn Pass DB Value

 Post Reply Post Reply
Author
BigMeat View Drop Down
Newbie
Newbie


Joined: 29 May 2003
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote BigMeat Quote  Post ReplyReply Direct Link To This Post Topic: Using asp:HyperLinkColumn Pass DB Value
    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

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
otaku View Drop Down
Newbie
Newbie


Joined: 01 June 2003
Location: Canada
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote otaku Quote  Post ReplyReply Direct Link To This Post 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>

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
otaku View Drop Down
Newbie
Newbie


Joined: 01 June 2003
Location: Canada
Status: Offline
Points: 15
Post Options Post Options   Thanks (0) Thanks(0)   Quote otaku Quote  Post ReplyReply Direct Link To This Post 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.

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.