|
 |
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 .
|
 |
|
|
 |

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
|
|
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
|

March 31st, 2007, 04:03 PM
|
 |
Friend of Wrox
Points: 16,481, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
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
|

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
|
|
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
|

March 31st, 2007, 08:58 PM
|
Wrox Author
Points: 13,255, Level: 49 |
|
|
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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
================================================== =========
|

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
|
|
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
|

April 1st, 2007, 08:48 AM
|
Wrox Author
Points: 13,255, Level: 49 |
|
|
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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
================================================== =========
|

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
|
|
Thanks, that did the trick.
|

April 1st, 2007, 10:09 AM
|
Wrox Author
Points: 13,255, Level: 49 |
|
|
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
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
================================================== =========
|

April 1st, 2007, 10:53 AM
|
 |
Wrox Author
Points: 72,055, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
|
|
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.
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |