Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > BOOK: Beginning ASP.NET 4.5 : in C# and VB
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB 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 May 17th, 2017, 11:47 AM
Registered User
 
Join Date: May 2017
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Ch.14 pg513 Try It Out. DataSource cannot be set declaratively

Hi,
I am currently working through Beginning ASP.NET 4.5, and have encountered a problem when going through the Try It Out that begins on pg. 513.
When switching to Design View in step 5, the repeater control has a message saying
"Error creating control-Repeater1
The DataSource cannot be set declaratively."

Attempting to compile leads to an error with the same "DataSource cannot be set declaratively" message, that when clicked highlights the BulletedList in AllByGenre.aspx file.
Below is the code for both AllByGenre.aspx and AllByGenre.aspx.vb.
Many thanks in advance to anyone who helps out a struggling newb!

Code:
<%@ Page Title="Reviews Grouped by Genre" Language="VB" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="false" CodeFile="AllByGenre.aspx.vb" Inherits="Reviews_AllByGenre" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
  <asp:Repeater ID="Repeater1" runat="server">
    <ItemTemplate>
      <h3><asp:Literal ID="Literal1" runat="server" Text='<&# Eval("Name") %>'></asp:Literal></h3>
      <asp:BulletedList ID="ReviewList" runat="server" DataSource='<&# Eval("Reviews") %>' DataTextField="Title" DisplayMode="Text"></asp:BulletedList>
    </ItemTemplate>
  </asp:Repeater>
</asp:Content>
Code:
Imports PlanetWroxModel

Partial Class Reviews_AllByGenre
  Inherits BasePage

  Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Using myEntities As New PlanetWroxEntities()
      Dim allGenres = From genre In myEntities.Genres.Include("Reviews")
                     Order By genre.Name
                     Select New With {genre.Name, genre.Reviews}
      Repeater1.DataSource = allGenres
      Repeater1.DataBind()
    End Using
  End Sub
End Class
 
Old May 17th, 2017, 01:52 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

You're binding the Text and DataSource properties incorrectly. Where you have an ampersand you should have a % symbol. I.e. this:

Text='<&# Eval("Name") %>'
DataSource='<&# Eval("Reviews") %>'

should be this:

Text='<%# Eval("Name") %>'
DataSource='<%# Eval("Reviews") %>'

Hope this helps,

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!
The Following User Says Thank You to Imar For This Useful Post:
doc11235 (May 18th, 2017)
 
Old May 18th, 2017, 03:12 AM
Registered User
 
Join Date: May 2017
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi Imar,
Many thanks for the prompt and incisive reply, loving your work! Tired eyes and clumsy fingers conspired against me at the end of a long day!
Best regards,
Alex.
 
Old May 24th, 2017, 05:03 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Alex,

>> Tired eyes and clumsy fingers conspired against me at the end of a long day!

Welcome to my world ;-)

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch.14 first try it out lrk89 BOOK: Beginning ASP.NET 4 : in C# and VB 7 February 10th, 2014 05:12 PM
Ch.14 - First try it out jxFive BOOK: Beginning ASP.NET 4 : in C# and VB 3 November 3rd, 2011 03:55 PM
Ch 14 Help digink BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 November 3rd, 2009 03:35 PM
How to Set DataSource in a Skin File NickTUK ASP.NET 3.5 Basics 1 October 28th, 2009 03:41 PM
Author claims default value can’t be set declaratively carewithl BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 October 14th, 2009 01:22 PM





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