Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : 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 November 19th, 2016, 05:17 AM
Registered User
 
Join Date: Nov 2016
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 14 A simple model binding application

Hi Imar, thank you very much for all the prompt replies. I am stuck at pg508 Creating NewPhotoAlbum.aspx After following every steps, I got 2 errors, 1st is 'PhotoAlbums' is not a member of 'PlanetWroxEntities'. 2nd is 'Id' is not a member of 'PhotoAlbum'.

Below are my codes

Partial Class _NewPhotoAlbum
Inherits BasePage

Public Sub DetailsView1_InsertItem()
Dim photoAlbum As New PhotoAlbum()
TryUpdateModel(photoAlbum)
If ModelState.IsValid Then
Using myEntities As New PlanetWroxEntities()
myEntities.PhotoAlbums.Add(photoAlbum)
myEntities.SaveChanges()
End Using
Response.Redirect(String.Format("ManagePhotoAlbum? PhotoAlbumId={0}", photoAlbum.Id.ToString()))
End If
End Sub
End Class

<%@ Page Title="Create New Photo Album" Language="VB" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="false" CodeFile="NewPhotoAlbum.aspx.vb" Inherits="_NewPhotoAlbum" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
<asp:DetailsView AutoGenerateRows="false" ID="DetailsView1" runat="server" DefaultMode="Insert" InsertMethod="DetailsView1_InsertItem" >
<Fields>
<asp:BoundField DataField="Name" HeaderText ="Name" />
<asp:CommandField ShowInsertButton ="True" ShowCancelButton ="false" />
</Fields>
</asp:DetailsView>
</asp:Content>

The PlanetWrox.edmx
https://s3.postimg.org/fj3h9dr8f/Scr...v_19_17_13.jpg

Please help. I am not sure why the errors occurred.
 
Old November 21st, 2016, 11:15 AM
Registered User
 
Join Date: Nov 2016
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solved.

In Step 2 of page 506, instead of creating a new database diagram and add PhotoAlbum and Picture table. I added the 2 table in the Reviews and Genre Database Diagram. Once I created the new database diagram and added the 2 tables and continued, the errors went away.
 
Old November 22nd, 2016, 05:42 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, that was the intent. From the book:

Quote:
On the Object Explorer, open the database diagram that you created in Chapter 12. Right click the diagram and choose Add Table.
Glad you got it to work.

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
hapter 14 Third Try It Out A Simple Model Binding Application, page 505 yasirmehmood BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 11 March 24th, 2016 03:45 AM
Chapter 14 Third Try It Out A Simple Model Binding Application, p.505 arvalon BOOK: Beginning ASP.NET 4.5.1 : in C# and VB 3 February 17th, 2016 07:47 AM
Chapter 14: Simple EntitySource Application try-it out K_Joe BOOK: Beginning ASP.NET 4 : in C# and VB 7 February 16th, 2014 05:00 PM
Chapter 14 : Mapping data model to an object model robochrish BOOK: Beginning ASP.NET 4 : in C# and VB 8 March 5th, 2013 09:52 AM
Chapter 14: Entity Model Code WILL NOT WORK! pittfurg BOOK: Beginning ASP.NET 4 : in C# and VB 6 February 28th, 2013 07:48 AM





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