Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 23rd, 2005, 03:02 PM
Authorized User
 
Join Date: Aug 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hyperlink to another page with data

Hello all,

I was really hoping someone could help me with this problem.

I want to make a datagrid with a Hyperlink colum:

<asp:datagrid id="datagrid1" runat="server">
<columns>
<asp:Hyperlinkcolumn
    HeaderText = "Select a Joke"
    DataTextField = "Headline"
    DataNavigateUrlField = "Blankpage.aspx"
    Target = "_blank" />
<columns>
</asp:datagrid>

The hyperlink colum reference a datafield called "Headline". I would like to create this so when a user click a link, they are directed to a blank page.
And this blank page will dynamically display the contents of clicked item which includes the "Headline" and "Story" Datafields of the clicked item.

Can anyone help me with this or put me in the right direction as to I would go about making this.

thanks,

Ray

 
Old September 24th, 2005, 06:02 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Ray

Just use the code below for your datagrid (DONT FORGET TO BIND THE GRID IN CODEBEHING)

Note:
1) Text in green denotes the fields passed in querystring to the next page
2) Text in Red shows the header for your Hyperlink.


<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink Runat="server" NavigateUrl='<%#"redirectpage.aspx?cHeadLine="+Dat aBinder.Eval(Container.DataItem,"Headline")+"&cSto ry="+DataBinder.Eval(Container.DataItem,"Story")%> '>
<%#DataBinder.Eval(Container.DataItem,"Headline")% >
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>




 
Old September 26th, 2005, 01:41 PM
Authorized User
 
Join Date: Aug 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Mike,

thank you for your reply. I forgot to ask what is needed on the destination page to place the content. I assume it is a label. Would it be a label with the id="Headline" and another label with the id="Story"

thanks,

Ray

 
Old September 27th, 2005, 03:15 AM
Friend of Wrox
 
Join Date: Aug 2004
Posts: 550
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hey Ray

These values are passed to the next page as querystrings, so you can use these querystrings, and display where ever you want.

e.g.. TextBox1.Text=Request.Querystring["cStory"].ToString()
      TextBox2.Text=Request.Querystring["cHeadLine"].ToString()


Take Care
Mike


 
Old September 27th, 2005, 08:30 AM
Authorized User
 
Join Date: Aug 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Mike.

I really appreciate all your help. I am a bit new to this and have not had much experience with code behinding as you mentioned to do in your original post. I am assuming you mean to do all the database connectivity and datareader stuff as reusable code link to the 2 pages (Source and destination). Is that right? Or s there another process involved. If you could explaint this a bit further, I would appreciate it.

thanks,

Ray






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink on page 55 rhoss BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 July 6th, 2008 01:12 PM
Hyperlink url too long in data grid. Hughesie78 ASP.NET 2.0 Professional 2 May 12th, 2008 11:54 AM
Hyperlink in asp page ppenn Classic ASP Databases 2 September 27th, 2007 02:09 PM
hyperlink inside a page debjanib ASP.NET 1.0 and 1.1 Basics 4 December 1st, 2006 02:04 PM
have to hyperlink the data retrieved ractim ADO.NET 21 August 27th, 2004 09:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.