Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 3rd, 2009, 06: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
  #2 (permalink)  
Old April 4th, 2009, 01: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)
  #3 (permalink)  
Old April 4th, 2009, 10: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.
  #4 (permalink)  
Old April 7th, 2009, 08: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.
  #5 (permalink)  
Old April 9th, 2009, 03: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
 


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
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 03: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



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


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