Re: 'String was not recognized as a valid DateTime
- From: "sachintana" <sachintana@xxxxxxxxxxx>
- Date: Thu, 21 Apr 2005 10:34:37 +0600
Error occured when openDate query string is not in the date format
(mm/dd/yyyy).
Please use try, catch between your code lines.
And check whether the _opendate variable is null before using it.
private DateTime _opendate;
try
{
_opendate = DateTime.Parse(Request.Form["openDate"]);
}
catch(FormatException ex)
{
_opendate = null;
}
if(_opendate!=null)
{
//Do what ever you want
}
Best regards,
sachintana-MCSD.NET
"Pial" zislam@xxxxxxxxx wrote in message
news:795114e5.0504200539.32a72af1@xxxxxxxxxxxxxxxxxxxxx
>I am facing problem in the following situation:
>
>
> I have a text box in the aspx file name: openDate. And my date format is
> mm/dd/yyyy.
>
> C#:
>
> private DateTime _opendate;
>
> _openDate = DateTime.Parse(Request.Form["openDate"]);
>
> I get error saying 'String was not recognized as a valid DateTime'
>
> thanks in advance
>
> Zahir
.
- References:
- Prev by Date: Re: 'String was not recognized as a valid DateTime
- Next by Date: Re: How do you set up http://localhost?
- Previous by thread: Re: 'String was not recognized as a valid DateTime
- Next by thread: Re: 'String was not recognized as a valid DateTime
- Index(es):
Loading