Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 30th, 2007, 04:03 PM
Authorized User
 
Join Date: Feb 2007
Location: Bend, Oregon, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening a customized page

Ok, I am having a tough time understanding how to do this. I have a series of names that I pull from a database and then display as hyperlinks.

When a user clicks on a name I want to be able to open a detailed page with that "names" information. I've read about PostBackURL but is does not seem to work with a hyperlink. Is there a specific control that I need to use?

Thanks for the help

Reply With Quote
  #2 (permalink)  
Old March 31st, 2007, 04:03 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What do you have so far?

Usually this is just done with hyperlinks to the details page that define a userid on it in the query string. Then you get the id from the query string over on the detail page and serve up whatever details you want to show. Just look at the user names next to the posts in this thread... your's comes up as this: http://p2p.wrox.com/pop_profile.asp?...splay&id=58645


-Peter
Reply With Quote
  #3 (permalink)  
Old March 31st, 2007, 08:37 PM
Authorized User
 
Join Date: Feb 2007
Location: Bend, Oregon, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ok here is what I am trying to do: I have generated a datalist of Company Names that appear as hyperlinks, then when the user clicks on a company link the client's page should open up. I am trying to tailor the navigate URL to include the PKClient for the look up but I keep getting the following error: Overload resolution failed because no accessible 'Eval' accepts this number of arguments.


Here is the code that I am trying to use:
<ItemTemplate>
                <asp:HyperLink ID="ClientName" runat="server" Text='<%# Eval("ClientName") %>' NavigateUrl='<%# Eval("PKClient", "ClientSummary.aspx?PKClient={0}" %>'></asp:HyperLink>
            </ItemTemplate>

Thanks for the help
Reply With Quote
  #4 (permalink)  
Old March 31st, 2007, 08:58 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Eval is meant to reference a column in the datasource, it only takes one argument: the column name.

This is not valid
<%# Eval("PKClient", "ClientSummary.aspx?PKClient={0}" %>

I might suggest adding a column to your datasource that contains the necessary link.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Reply With Quote
  #5 (permalink)  
Old March 31st, 2007, 09:30 PM
Authorized User
 
Join Date: Feb 2007
Location: Bend, Oregon, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My datasource does contain the PKClient.

"SELECT Client.ClientName, Client.PKClient FROM Client"

I think the issue is with how to build the navigate url to contain the PKClient.

This code attempts to open a page with the URL of "PKClient" and works. Although, the URL only contains the PKClient and not the page reference.
<ItemTemplate>
                <asp:HyperLink ID="ClientNameLabel" runat="server" Text='<%# Eval("ClientName") %>' NavigateUrl='<%# Eval("PKClient") %>'>
                </asp:HyperLink><br />

I just can't get the URL to have both the base URL plus the changing PKClient

Reply With Quote
  #6 (permalink)  
Old April 1st, 2007, 08:48 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

To get the url with the correct pk do something like this:

"SELECT Client.ClientName, 'ClientSummary.aspx?PKClient=' + Client.PKClient as URL FROM Client"

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Reply With Quote
  #7 (permalink)  
Old April 1st, 2007, 10:00 AM
Authorized User
 
Join Date: Feb 2007
Location: Bend, Oregon, USA.
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that did the trick.

Reply With Quote
  #8 (permalink)  
Old April 1st, 2007, 10:09 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No problem, glad it worked out of your.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Reply With Quote
  #9 (permalink)  
Old April 1st, 2007, 10:53 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I hate to spoil the fun, but I wouldn't recommend doing this.

First of all, Eval *does* have an overload that allows you to format the expression: http://msdn2.microsoft.com/en-us/library/2d76z3ck.aspx

The DataBinder class has two overloads: one that accepts the object and a single string (the name of the property on the object) and another one that accepts an additional format expression.

Snuffles: the code you posted was, as Doug said, invalid. However, this isn't because Eval doesn't have an overload, but because you were missing a ):

NavigateUrl='<%# Eval("PKClient", "ClientSummary.aspx?PKClient={0}"%>'

should be

NavigateUrl='<%# Eval("PKClient", "ClientSummary.aspx?PKClient={0}")%>'

Notice the additional ) between the " and the %. You just forgot to close the call to Eval.

With the ) in place, your example will run fine.

Personally, I would never hard code the path in my select statement against the database. It makes it really hard to reuse the same code in a different scenario. It also makes it near impossible for others to find out why a certain page redirects to some location. Using the Format expression as you posted is, IMO, the best way to go.
As an alternative, you could have also used simple string concatenation:

NavigateUrl='<%# "ClientSummary.aspx?PKClient=" + Eval("PKClient") %>'>


Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a saved Outlook customized form Arsi BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 3 January 11th, 2012 04:47 PM
Opening page layout... photon BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 October 7th, 2008 04:22 PM
Internet Page Opening eyuvaraj Beginning VB 6 6 August 22nd, 2006 08:42 AM
Error while opening an aspx page manchanahari ASP.NET 1.0 and 1.1 Basics 1 February 15th, 2006 09:43 AM
Customized error page for missing records karib Classic ASP Databases 13 March 23rd, 2004 12:59 PM



All times are GMT -4. The time now is 03:18 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.