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 July 3rd, 2017, 10:00 AM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jul 2017
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Cool Ch. 14 NewPhotoAlbum.aspx error

I am trying to do the try it out section, "A Simple EntityDataSource Application" but when I run the NewPhotoAlbum.aspx page I receive the following error:

'PhotoAlbum' is not a member of type 'PlanetWroxModel.Picture' in the currently loaded schemas. Near simple identifier, line 6, column 4.

I have checked my where clause as suggested in another post about this, but I cannot see the issue. Can you offer me any help please?

My code is as follows:

ManagePhotoAlbum.aspx
Code:
<%@ Page Title="Manage Photo Album" Language="C#" MasterPageFile="~/MasterPages/ManagementMaster.master" AutoEventWireup="true" CodeFile="ManagePhotoAlbum.aspx.cs" Inherits="ManagePhotoAlbum" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="Id" DataSourceID="EntityDataSource1" InsertItemPosition="LastItem">
        <InsertItemTemplate>
            <li style="">Description:
                <asp:TextBox ID="DescriptionTextBox" runat="server" Text='<%# Bind("Description") %>' />
                <br />ToolTip:
                <asp:TextBox ID="ToolTipTextBox" runat="server" Text='<%# Bind("ToolTip") %>' />
                <br />ImageUrl:
                <asp:TextBox ID="ImageUrlTextBox" runat="server" Text='<%# Bind("ImageUrl") %>' />
                <br />
                <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
                <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
            </li>
        </InsertItemTemplate>
        <ItemTemplate>
            <li style="">
                Description:
                <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>' />
                <br />
                ToolTip:
                <asp:Label ID="ToolTipLabel" runat="server" Text='<%# Eval("ToolTip") %>' />
                <br />
                ImageUrl:
                <asp:Label ID="ImageUrlLabel" runat="server" Text='<%# Eval("ImageUrl") %>' />
                <br />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
            </li>
        </ItemTemplate>
        <LayoutTemplate>
            <ul class="ItemContainer">
                <li runat="server" id="itemPlaceholder" />
            </ul>
        </LayoutTemplate>
    </asp:ListView>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=PlanetWroxEntities" DefaultContainerName="PlanetWroxEntities1" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EntitySetName="Pictures" Where="it.PhotoAlbum.Id = @photoAlbumId" OnInserting="EntityDataSource1_Inserting">
        <WhereParameters>
            <asp:QueryStringParameter Name="PhotoAlbumId" QueryStringField="PhotoAlbumId" Type="Int32" />
        </WhereParameters>
    </asp:EntityDataSource>
</asp:Content>
NewPhotoAlbum.aspx
Code:
<%@ Page Title="New Photo Album" Language="C#" MasterPageFile="~/MasterPages/ManagementMaster.master" AutoEventWireup="true" CodeFile="NewPhotoAlbum.aspx.cs" Inherits="NewPhotoAlbum" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" Runat="Server">
    <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="EntityDataSource1" DefaultMode="Insert" Height="50px" Width="125px">
        <Fields>
            <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" InsertVisible="false"/>
            <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
            <asp:CommandField ShowInsertButton="True" />
        </Fields>
    </asp:DetailsView>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=PlanetWroxEntities1" DefaultContainerName="PlanetWroxEntities1" EnableFlattening="False" EnableInsert="True" EntitySetName="PhotoAlbums" OnInserted="EntityDataSource1_Inserted">
    </asp:EntityDataSource>
</asp:Content>
NewPhotoAlbum.aspx.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PlanetWroxModel;

public partial class NewPhotoAlbum : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void EntityDataSource1_Inserted(object sender, EntityDataSourceChangedEventArgs e)
    {
        PhotoAlbum myPhotoAlbum = (PhotoAlbum)e.Entity;
        Response.Redirect(string.Format("ManagePhotoAlbum.aspx?PhotoAlbumId={0}",myPhotoAlbum.Id.ToString()));
    }
    protected void EntityDataSource1_Inserting(object sender, EntityDataSourceChangingEventArgs e)
    {
        int photoAlbumId = Convert.ToInt32(Request.QueryString.Get("PhotoAlbumId"));
        Picture myPicture = (Picture)e.Entity;
        myPicture.PhotoAlbumId = photoAlbumId;
    }


}
Reply With Quote
  #2 (permalink)  
Old July 4th, 2017, 09:12 AM
Imar's Avatar
Wrox Author
Points: 71,090, Level: 100
Points: 71,090, Level: 100 Points: 71,090, Level: 100 Points: 71,090, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,935
Thanks: 79
Thanked 1,553 Times in 1,530 Posts
Default

Hi there,

How did you set up the database? Did you create the proper foreign key relationships between Picture and PhotoAlbum? Also, did you name your tables correctly before you added them to the diagram?

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
  #3 (permalink)  
Old July 4th, 2017, 09:24 AM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jul 2017
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thank you for replying to my post.

I created the database by dragging and dropping the database from the BegASPNET folder. I realise now that this may be incorrect because it is a resource from your 3.5 book and I am using the try it out section from Chapter 14 of your 4.5 book. I will try to set up the database differently, if you think it might help? In SSManager I created a database as per the instructions in your 4.5 book but I am not sure that it is connected to VS. The tables I created there have the foreign key relationships between Picture and PhotoAlbum and from what I can see, the tables are named correctly.
Reply With Quote
  #4 (permalink)  
Old July 4th, 2017, 10:11 AM
Registered User
Points: 37, Level: 1
Points: 37, Level: 1 Points: 37, Level: 1 Points: 37, Level: 1
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jul 2017
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,

I recreated the foreign key relationship between the Picture and PhotoAlbum tables and that fixed the problem. I had created the database correctly after checking it again as per your 4.5 book.

Thanks for helping me fix my issue.
Reply With Quote
  #5 (permalink)  
Old July 4th, 2017, 03:01 PM
Imar's Avatar
Wrox Author
Points: 71,090, Level: 100
Points: 71,090, Level: 100 Points: 71,090, Level: 100 Points: 71,090, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,935
Thanks: 79
Thanked 1,553 Times in 1,530 Posts
Default

Great, glad to hear it's working now....
__________________
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
  #6 (permalink)  
Old July 6th, 2017, 07:20 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 33%
Activity: 33% Activity: 33% Activity: 33%
 
Join Date: Jul 2017
Location: Mumbai
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Inclined Cleated Belt Conveyors

Inclined Cleated Belt Conveyors are mainly used for controlling the product on an inclined conveyor line.
Meeting the horizontal/inclined conveying requirements, these conveyors find use in food grade applications requiring wash down post which material is transferred in incline.
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
Error in Ch. 14 example 1 TheWildJacko BOOK: Beginning JavaScript 5th Edition 3 March 1st, 2017 04:15 PM
Error in Ch. 14 Try It Out FrugalRacer BOOK: Beginning ASP.NET 4 : in C# and VB 5 September 29th, 2014 06:38 AM
Chapter 14 - All.aspx error Dbug BOOK: Beginning ASP.NET 4.5 : in C# and VB 6 September 18th, 2013 09:13 AM
Ch.14 .NETFramework error smileys6971 BOOK: Beginning ASP.NET 4 : in C# and VB 8 February 25th, 2013 01:06 PM
ch 14: AllByGenre.aspx.cs binaryspirit BOOK: Beginning ASP.NET 4 : in C# and VB 6 May 4th, 2012 09:08 AM



All times are GMT -4. The time now is 04:52 AM.


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