Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4.5 > BOOK: Beginning ASP.NET 4.5 : in C# and VB
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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 17th, 2017, 11:47 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
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
Reply With Quote
  #2 (permalink)  
Old May 17th, 2017, 01:52 PM
Imar's Avatar
Wrox Author
Points: 71,054, Level: 100
Points: 71,054, Level: 100 Points: 71,054, Level: 100 Points: 71,054, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,927
Thanks: 79
Thanked 1,553 Times in 1,530 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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
doc11235 (May 18th, 2017)
  #3 (permalink)  
Old May 18th, 2017, 03:12 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 50%
Activity: 50% Activity: 50% Activity: 50%
 
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.
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
Ch.14 first try it out lrk89 BOOK: Beginning ASP.NET 4 : in C# and VB 7 February 10th, 2014 04: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 02: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



All times are GMT -4. The time now is 04:34 PM.


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