Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 Display Modes
  #1 (permalink)  
Old May 19th, 2010, 03:25 PM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default Reviews

Hello,
We have a link to detailed review on All.Aspx page but on the AllByGenre.aspx we have just bulleted list with its Genre heading.
How we can provide a link to details page on the AllByGenre.aspx page itself.

Code:
<asp:HyperLink ID="HyperLink1" runat="server" 
          NavigateUrl='<%# "ViewDetails.aspx?StarId=" + Eval("Id").ToString() %>' 
          Text='<%# Eval("Title") %>'></asp:HyperLink>
This does not work on the AllByGenre.aspx page. I also pasted the related DataContext code in .vb file.

How We Can get reference to Title and Id within this code.
Code:
Dim allGenres = From genre In myDataContext.Genres _
                    Order By genre.Name _
                    Select New With {genre.Name, genre.Reviews}
So how it would be possible to achieve the same.
Thanks.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
Reply With Quote
  #2 (permalink)  
Old May 19th, 2010, 04:12 PM
Imar's Avatar
Wrox Author
Points: 67,100, Level: 100
Points: 67,100, Level: 100 Points: 67,100, Level: 100 Points: 67,100, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,202
Thanks: 65
Thanked 1,405 Times in 1,385 Posts
Default

Quote:
This does not work on the AllByGenre.aspx page.
Can you define "does not work" Do you get an error? If so, which one? What exactly are you trying to accomplish? I can't read your mind, you know....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old May 19th, 2010, 04:25 PM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

DataBinding: 'VB$AnonymousType_0`3[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Data.Linq.EntitySet`1[[StarReview, App_Code.epf1pbae, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' does not contain a property with the name 'Id'.

This is the error that I am getting if I try to provide a link for viewdetails.aspx page through the AllByGenre.aspx page which you are providing on the All.aspx page. For this I have pasted the hyperlink code (as mentioned in last post) on the AllByGenre.aspx page, but as this hyperlink needs to get the values for Id and Title hence in the .vb file it should be bound to the Repeater , but I am not getting the reference for the same.

So finally I am asking how we can get reference to Id and Title property.
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
Reply With Quote
  #4 (permalink)  
Old May 19th, 2010, 05:13 PM
Imar's Avatar
Wrox Author
Points: 67,100, Level: 100
Points: 67,100, Level: 100 Points: 67,100, Level: 100 Points: 67,100, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,202
Thanks: 65
Thanked 1,405 Times in 1,385 Posts
Default

The error is on line 7...

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #5 (permalink)  
Old May 21st, 2010, 09:06 AM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Quote:
The error is on line 7...
In last post? If so then what is wrong with that?
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
Reply With Quote
  #6 (permalink)  
Old May 21st, 2010, 02:58 PM
Imar's Avatar
Wrox Author
Points: 67,100, Level: 100
Points: 67,100, Level: 100 Points: 67,100, Level: 100 Points: 67,100, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,202
Thanks: 65
Thanked 1,405 Times in 1,385 Posts
Default

It's an old joke, and it better reads like this:

Exactly
> How do you know? I didn't post any code?
>> The error is on line 7

In other words, you haven't posted the code needed to make a succesful suggestion.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #7 (permalink)  
Old May 21st, 2010, 03:14 PM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Quote:
you haven't posted the code needed to make a succesful suggestion.
I posted the code in my first post and I pointed it out in my last post.
Any ways the code was
Code:
<asp:HyperLink ID="HyperLink1" runat="server" 
          NavigateUrl='<%# "ViewDetails.aspx?StarId=" + Eval("Id").ToString() %>' 
          Text='<%# Eval("Title") %>'></asp:HyperLink>
Now I am trying to provide the link for the ViewDetails Page on the AllByGenre.aspx page itself. but as t requires now the reference for Id & Title so I need to have a reference in the code behind as well, but in the code behind file
Code:
Dim allGenres = From genre In myDataContext.Genres _
                    Order By genre.Name _
                    Select New With {genre.Name, genre.Reviews}
I am not able to get reference for the Id, And Title so I get the error

DataBinding: 'VB$AnonymousType_0`3[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Data.Linq.EntitySet`1[[StarReview, App_Code.epf1pbae, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' does not contain a property with the name 'Id'.

So how we can bind Repeater with the Id & Title in code behind file
Thank you
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
Reply With Quote
  #8 (permalink)  
Old May 21st, 2010, 04:44 PM
Imar's Avatar
Wrox Author
Points: 67,100, Level: 100
Points: 67,100, Level: 100 Points: 67,100, Level: 100 Points: 67,100, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,202
Thanks: 65
Thanked 1,405 Times in 1,385 Posts
Default

I don't see a Repeater nor other important code.

You post a HyperLink and a LINQ query and that's it. No way for us to see how you hook them up, how the Repeater gets its data, how the HyperLink is positioned in the Repeater and so on and so forth.

I said it before and I'll say it again: I can't read your mind and I can't look into your Visual Studio IDE. Just for fun, look over your own posts, try to forget what you already know about this and see if you can understand your own questions....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #9 (permalink)  
Old May 22nd, 2010, 01:07 PM
Friend of Wrox
Points: 752, Level: 10
Points: 752, Level: 10 Points: 752, Level: 10 Points: 752, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
Default

Repeater has the following code with hyperlink as follows in AllByGenre.aspx
Code:
<asp:Repeater ID="Repeater1" runat="server">
		<ItemTemplate>
			<h3><asp:Literal ID="Literal1" runat="server" Text='<%# Eval("Name") %>'></asp:Literal></h3>
 <asp:HyperLink ID="HyperLink1" runat="server" 
          NavigateUrl='<%# "ViewDetails.aspx?ReviewId=" + Eval("Id").ToString() %>' 
          Text='<%# Eval("Title") %>'></asp:HyperLink>
			<asp:BulletedList ID="lstReviews" runat="server" DataSource='<%# Eval("Reviews")%>' DataTextField="Title" DisplayMode="Text">
			</asp:BulletedList>
		</ItemTemplate>
	</asp:Repeater>
And the code behind file has the following code
Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
           Using myDataContext As New DataContext()

           Dim allGenres = From genre In myDataContext.Genres _
                    Order By genre.Name _
                    Select New With {genre.Name, genre.Reviews}

            Repeater1.DataSource = allGenres
            Repeater1.DataBind()
        End Using
    End Sub
Now the hyperlink uses Id and Title to be bound but in code behind file I do not get any reference to those so how we can get reference to those.
Thank you
__________________
Jack: Founder, Developer & Owner Of JackAndGenieForever.Com
Reply With Quote
  #10 (permalink)  
Old May 23rd, 2010, 05:16 AM
Imar's Avatar
Wrox Author
Points: 67,100, Level: 100
Points: 67,100, Level: 100 Points: 67,100, Level: 100 Points: 67,100, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,202
Thanks: 65
Thanked 1,405 Times in 1,385 Posts
Default

Your HyperLink is directly in the ItemTemplate which means you're using it to display a genre, not a review. Is that what you're trying to accomplish?

Otherwise, use a nested Repeater, similar to how the BulletedList is now nested in the outer Repeater and use ='<%# Eval("Reviews")%>' as its data source.

Quote:
Just for fun, look over your own posts, try to forget what you already know about this and see if you can understand your own questions....
Did you try this?


Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
Reply


Thread Tools
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
Chapter 4:Displaying the reviews p.126-128 drgnhiker BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 6 November 6th, 2010 04:04 AM
problems with the reviews table in chapter 4 derrida BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 March 15th, 2007 03:58 AM
I've read some bad reviews; what do readers think? disruptivehair BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 11 January 18th, 2006 03:44 PM



All times are GMT -4. The time now is 10:33 AM.


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