Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 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 April 3rd, 2009, 05:03 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default Object Reference not set

Hi all again.

Another productive week of coding, debugging and learning!

I have gotten my AETransfers.aspx up working great and it brings you to AETransfer.aspx when you select Add New Transfer.

The form comes up the logic to display certain parts of the form load as should.
I fill the form out, and press save and I get the following error in my LoadObject from Screen block: Object Reference not set to an instance of an object.

It points to the baseEO.pName = pName.Text;
To get to where I am at I followed the pattern used in the Administration/Users.aspx and Administration/User.aspx pages. The pName.Text is not null and I have verified that the data is being passed. Any idea as to what it could be looking for or what I need to do to correct it?

Code:
protectedoverridevoid LoadObjectFromScreen(AETransfersEO baseEO)
{
    baseEO.pName = pName.Text;
    baseEO.RequestDate = Convert.ToDateTime(reqDate.Text);
    baseEO.dob = Convert.ToDateTime(dob.Text);
    baseEO.transFacility = transFacility.SelectedValue.ToString();
    baseEO.facilityPhone = facilityPhone.Text;
    baseEO.personCalling = personCalling.Text; 
}
Here is my Save Method

Code:

void Master_SaveButton_Click(object sender, EventArgs e)
{
ENTValidationErrors validationErrors = newENTValidationErrors();
AETransfersEO aETransfer = (AETransfersEO)ViewState[VIEW_STATE_KEY_AETRANSFER];
LoadObjectFromScreen(aETransfer);
 
if (!aETransfer.Save(ref validationErrors, 1))
{
Master.ValidationErrors = validationErrors;
}
else
{
GoToGridPage();
} 

Thanks
 
Old April 4th, 2009, 12:51 AM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Is it possible that the offending null object is actually aETransfer? Did you put it in the ViewState in LoadScreenFromObject?

If you haven't already, put a breakpoint on the line AETransfersEO aETransfer = (AETransfersEO)ViewState[VIEW_STATE_KEY_AETRANSFER]; and step through the code from there.

The code looks right as posted, so it's probably something relatively simple (like a typo in an ID).

At least, that's my two cents (not ajdusted for inflation)...

Tim
The Following User Says Thank You to Corsair For This Useful Post:
ZeroFactorial (April 7th, 2009)
 
Old April 4th, 2009, 09:48 AM
Wrox Author
 
Join Date: Jan 2009
Posts: 73
Thanks: 0
Thanked 7 Times in 7 Posts
Default

Usually when this occurs it is because the EO object wasn't saved to the ViewState in the LoadScreenFromObject method as Tim said.
 
Old April 7th, 2009, 07:38 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Thanks for the replies everyone.

Tim what you pointed out was the problem.
Guess too many long hours will get you over looking the simple things.

I actually had it in the LoadScreenfromObject but it was commented out since I was testing something else. Thanks for bringing that to my attention. I suffer from making simple things complicated syndrome.
 
Old April 9th, 2009, 02:06 AM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Glad to be able to help. I understand the whole not seeing the forest for the trees problem.

And I'm willing to bet that I can make simple things more complicated than you can :)

Tim





Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of object iceman90289 ASP.NET 3.5 Basics 1 March 1st, 2009 05:13 AM
object reference not set to instant of an object shahidrasul ASP.NET 2.0 Basics 1 September 5th, 2008 02:01 PM
Object reference not set flashmanTom BOOK: Beginning VB.NET Databases 1 February 19th, 2008 06:29 AM
Object Reference not set to an instance of object srinivas_chakka ASP.NET 1.0 and 1.1 Professional 0 February 8th, 2006 11:56 AM





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