none
I Need To Filter Gridview From Starting Date to Ending Date. Please Correct my Code RRS feed

  • Question

  • DateTime StartingDate;

    DateTime EndingDate;

    bs.Filter = "[OrderDate] >= #" + StartingDate + "#"+"[OrderDate] <= #"+EndingDate+"#";

    Tuesday, December 23, 2014 11:32 AM

Answers

  • The following code should work:

    bs.Filter = String.Format("OrderDate >= '{0:yyyy-MM-dd}' AND OrderDate <= '{1:yyyy-MM-dd}'", StartingDate, EndingDate);
    

    Please remember to mark helpful posts as answer and/or helpful.
    • Marked as answer by RAGU DEVA Wednesday, December 24, 2014 7:12 AM
    Tuesday, December 23, 2014 3:14 PM

All replies

  • The following code should work:

    bs.Filter = String.Format("OrderDate >= '{0:yyyy-MM-dd}' AND OrderDate <= '{1:yyyy-MM-dd}'", StartingDate, EndingDate);
    

    Please remember to mark helpful posts as answer and/or helpful.
    • Marked as answer by RAGU DEVA Wednesday, December 24, 2014 7:12 AM
    Tuesday, December 23, 2014 3:14 PM
  • Thank U Very Much
    Wednesday, December 24, 2014 7:13 AM