Welcome Guest Search | Active Topics | Sign In | Register

Date Picker Null Object Reference Options
PMAC
Posted: Wednesday, April 15, 2009 4:53:45 PM
Rank: Member
Groups: Member

Joined: 4/15/2009
Posts: 14
When I am trying to read the SelectedDate value I get a null reference error. I have AutoPostBack set to true?

Code: C#
DateTime.Parse(dpStartdate.SelectedDate.ToString())
eo_support
Posted: Wednesday, April 15, 2009 5:28:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

Please check the stack trace to see if it crashes inside that line or on that line. If it is inside that line (meaning that line called some other functions and the code crashed inside those function), then please provide the stack trace and we will be happy to take a look. We may need you to create a test page to reproduce the problem.

If it crashes on that line, then it is not likely to be our problem. SelectedDate will never be null because it is not a reference type. It is a value type. So in this case it is dpStartDate that is null. This often happens when you have a control declared in your .cs file (either in your .aspx.cs or .designer.cs) but you do not have a control with the same id in your .aspx file. In another word, your code and your markup are out of sync. This is an issue that can occur with any control and most of the time the mismatch is caused by Visual Studio (even though sometimes can be caused by hand). Usually the problem can be corrected by modifying the ID of any control in your page (so that Visual Studio will regenerate the .designer.cs file). However since it is not directly related to our product, we will not be able to provide more details on this. You can Google online and you should be able find plenty of resource on this issue.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.