Click here to Skip to main content
15,913,854 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

I am trying to write a method which can filter gridview from selected date range value, but I keep experiencing the following error (The name 'datetime' does not exist in the current context)on the "tryParse" if statement line below:

C#
private void BindDate(string startDate, string endDate)
   {

       DateTime dStartDate;
       DateTime dEndDate;
       DataSet dt = new DataSet();

       //Check if the string has the valid date format
       if (datetime.TryParse(startDate, out dStartDate) && datetime.TryParse(endDate, out dEndDate))
       {


If anyone knows what the error illustrate could you please let me know.
Many thanks for your time and help.
Posted

Replace
C#
datetime.TryParse

with
C#
DateTime.TryParse


Refer:http://msdn.microsoft.com/en-us/library/ch92fbc1(v=vs.110).aspx[^]

This may work.
 
Share this answer
 
v2
Comments
miss786 13-Jan-14 6:15am    
Thank you! =D
Gitanjali Singh 13-Jan-14 6:17am    
welcome :)
Try this
C#
if (DateTime.TryParse(startDate, out dStartDate) && DateTime.TryParse(endDate, out dEndDate))
       {


datetime - > DateTime

Reference : DateTime.TryParse[^]
 
Share this answer
 
v2
datetime should be DateTime


C#
private void BindDate(string startDate, string endDate)
   {

       DateTime dStartDate;
       DateTime dEndDate;
       DataSet dt = new DataSet();

       //Check if the string has the valid date format
       if (DateTime.TryParse(startDate, out dStartDate) && DateTime.TryParse(endDate, out dEndDate))
       {
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900