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())
|
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!
|