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

May 19th, 2010, 03:25 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
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.
|
|

May 19th, 2010, 04:12 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

May 19th, 2010, 04:25 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
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.
|
|

May 19th, 2010, 05:13 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
The error is on line 7...
Imar
|
|

May 21st, 2010, 09:06 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
Quote:
|
The error is on line 7...
|
In last post? If so then what is wrong with that?
|
|

May 21st, 2010, 02:58 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

May 21st, 2010, 03:14 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
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
|
|

May 21st, 2010, 04:44 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

May 22nd, 2010, 01:07 PM
|
|
Friend of Wrox
|
|
Join Date: Sep 2009
Posts: 165
Thanks: 5
Thanked 6 Times in 6 Posts
|
|
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
|
|

May 23rd, 2010, 05:16 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |