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 7th, 2011, 12:38 PM
Authorized User
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default CH 14 A Simple EntityDataSource Application - Error!

OK so this has really got me now. Ive been looking over this all afternoon with no luck.

CH 14 A Simple EntityDataSource Application

I am getting an error in the code behind for the Id element in myNewClient.Id.ToString())), as shown below:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using clientManagerTestModel;

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

    }
    protected void EntityDataSource1_Inserted(object sender, EntityDataSourceChangedEventArgs e)
    {
        NewClient myNewClient = (NewClient)e.Entity;
        Response.Redirect(string.Format("ManageClient.aspx?Id={0}", myNewClient.Id.ToString()));
 
Old December 7th, 2011, 01:18 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

And the error is? And when do you get it? Please try to be as specifc as you can when you post here, or it's hard to impossible to help you.

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 7th, 2011, 01:20 PM
Authorized User
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default

Sorry!

this is the error I get:

Quote:
Error 1 'NewClient' does not contain a definition for 'Id' and no extension method 'Id' accepting a first argument of type 'NewClient' could be found (are you missing a using directive or an assembly reference?) C:\BegASPNET\clientManagerTest\NewClient.aspx.cs 20 81 C:\BegASPNET\clientManagerTest\
I get it when I F5 the page...
 
Old December 7th, 2011, 01:29 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Then maybe NewClient doesn't have an Id in the database? What does IntelliSense tell you?

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 7th, 2011, 01:42 PM
Authorized User
 
Join Date: Oct 2010
Posts: 71
Thanks: 12
Thanked 0 Times in 0 Posts
Default

Thanks.

There isnt a table called NewClient! It's simply Clients. I changed the coding to reflect this and this is what I have:


Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using clientManagerTestModel;

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

    }
    protected void EntityDataSource1_Inserted(object sender, EntityDataSourceChangedEventArgs e)
    {
        Client myClients = (Client)e.Entity;
        Response.Redirect(string.Format("ManageClient.aspx?Id={0}", myClients.Id.ToString()));
The page loads fine now... however, the UserId is not inserted into the table for Clients under the column UserName.

I am not getting any error other than the expected one for the next page - Manage Clients, not being available.
 
Old December 7th, 2011, 02:28 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
however, the UserId is not inserted into the table for Clients under the column UserName.
I don't see any code related to that, so I don't know what to recommend.

Quote:
There isnt a table called NewClient! It's simply Clients.
Does that mean you're not using IntelliSense to help you write this code?

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 .NETFramework error smileys6971 BOOK: Beginning ASP.NET 4 : in C# and VB 8 February 25th, 2013 02:06 PM
Ch 14: Try it Out p. 511 - error 'dependent property in a ReferentialConstraint' jayinatlanta BOOK: Beginning ASP.NET 4 : in C# and VB 2 November 6th, 2011 12:32 AM
Ch 14: Try it Out p. 510 - error 'PlanetWroxModel.Picture' is a 'type' jayinatlanta BOOK: Beginning ASP.NET 4 : in C# and VB 2 November 5th, 2011 09:50 AM
Error with EntityDataSource TeaDrinkingGeek BOOK: Beginning ASP.NET 4 : in C# and VB 3 March 20th, 2011 01:54 PM
CH 14 - Link Error - Unresolved Razzy The Pug BOOK: Ivor Horton's Beginning Visual C++ 2005 2 March 18th, 2008 06:44 PM





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