Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : 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 December 3rd, 2011, 03:51 PM
Registered User
 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default EntityDataSource Try it Out Exercise Page 497

Hi there!

I am a beginner but things have been going quite smoothly until this exercise on page 497 onwards on EntityDataSource control. I was find until step 8 when despite being data source being configured properly (as far as I can see!), the DetailsView control's columns won;t refresh to show Id and Name columns! When I try to refresh, I get an error message saying "Could not find CLR type for PlanetWroxModel.Photoalbum".

I would be grateful to get your help - I just can;t see anything wrong anywhere!
I have really enjoyed this book so far.

Thanks,
Bimal
 
Old December 4th, 2011, 06:08 AM
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,

Can you provide more information, such as the relevant code for the pages. Also, make sure you database was setup correctly (primary and foreign keys and so on) before you create the EDMX diagram.

Cheers,

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!
 
Old December 4th, 2011, 02:54 PM
Registered User
 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default EntityDataSource Try it Out - Chapter 14

THnaks very much for coming back, Imar. Here;s the code for the page o(NewPhotoAlbum.aspx):

Code:
<%@ Page Title="Create New Photo Album" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="NewPhotoAlbum.aspx.cs" Inherits="_NewPhotoAlbum" %>
<%@ Import Namespace="PlanetWroxModel" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:DetailsView ID="DetailsView1" runat="server" 
        DataSourceID="EntityDataSource1" Height="50px" Width="125px">
        <Fields>
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" 
        ConnectionString="name=PlanetWroxEntities" 
        DefaultContainerName="PlanetWroxEntities" EnableFlattening="False" 
        EntitySetName="Photoalbums" EnableDelete="True" EnableInsert="True" 
        EnableUpdate="True" EntityTypeFilter="Photoalbum">
    </asp:EntityDataSource>
</asp:Content>
 
Old December 4th, 2011, 03:27 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,

And what about the other info? Is the database set up correctly? How did you define the primary and foreign keys? And did you update the database before you created the model? And how exactly did you create this demo page? And is Photoalbum the right name or should it be PhotoAlbum?

Finally, when you use the sample page that comes with this book's download, does it work? (I am trying to find out of the issue is in the code, the model or the database).

Cheers,

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!
 
Old December 4th, 2011, 04:45 PM
Registered User
 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default EntityDataSource Try it Out - Chapter 14

Hi Imar,

Thanks for your prompt reply. I have checked all these issues and can't see anything wrong. I am sure I am missing something.

Is the database set up correctly? How did you define the primary and foreign keys?

As far as I can see, the primary and foreign keys are properly setup, i.e. Id in Photoalbum table is linked to PhotoalbumId in the Picture table.


And did you update the database before you created the model? And how exactly did you create this demo page?
Yes, I did.

And is Photoalbum the right name or should it be PhotoAlbum?
Probably not. But, this is the name used everywhere.

Finally, when you use the sample page that comes with this book's download, does it work?

Yes.


Many thanks,
Bimal
 
Old December 4th, 2011, 06:16 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If I compare my code with yours, I can see a few differences:

1. I don't have an Imports for the PlanetWroxModel namespace

2. You have an EntityTypeFilter set to Photoalbum which you don't need.

There are other differences but they shouldn't matter. What happens when you remove these two statements?

Also, my code has a DataKeyNames and yours doesn't, possible indicating an issue with the primary key in the database.

Quote:
Finally, when you use the sample page that comes with this book's download, does it work?

Yes.
Did you just copy in the code for this page (that is, are you using your model and database) or are you testing this on the full sample project?

If this still doesn't work, send me zipped copy of the project with just the necessary files to reproduce the problem and I'll take a look. My e-mail address is in the beginning of the book.

Cheers,

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!
 
Old December 5th, 2011, 01:27 PM
Registered User
 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default EntityDataSource Try it Out - Chapter 14

Thanks, Imar. I have changed things as suggested by you and now it seems to work.

Thanks very much. You have been really helpful,

Bimal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Update multiple tables with EntityDataSource alharlow ASP.NET 4 General Discussion 3 March 31st, 2011 03:15 AM
Error with EntityDataSource TeaDrinkingGeek BOOK: Beginning ASP.NET 4 : in C# and VB 3 March 20th, 2011 01:54 PM
Questions about EntityDataSource and dynamic binding Rushino ASP.NET 4 General Discussion 4 November 22nd, 2010 09:58 AM
Chapter 2, Page 76, Exercise 3 Chastini BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 1 March 25th, 2010 09:24 PM
Page 319: Exercise 1 kiwibrit BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 July 3rd, 2009 10:46 AM





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