Compare Datetime

4 posts, 0 answers
  1. arzie
    arzie avatar
    3 posts
    Member since:
    Apr 2011

    Posted 26 Dec 2012 Link to this post

    who compare datetime in radgrid itemdatabound? , please help
  2. rdmptn
    rdmptn avatar
    72 posts
    Member since:
    Aug 2011

    Posted 26 Dec 2012 Link to this post

  3. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Dec 2012 Link to this post

    Hi,

    Try the following code to compare dates.
    C#:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
      if (e.Item is GridDataItem)
      {
         GridDataItem item = (GridDataItem)e.Item;
         RadDatePicker picker1 = (RadDatePicker)item.FindControl("RadDatePicker1");
         RadDatePicker picker2 = (RadDatePicker)item.FindControl("RadDatePicker2");
         CompareValidator compValidate = (CompareValidator)item.FindControl("CompareValidator1");
         compValidate.ControlToValidate =picker1.ID;
         compValidate.ControlToCompare = picker2.ID;
         compValidate.ValueToCompare = DateTime.Now.ToShortDateString();
         compValidate.Type = ValidationDataType.Date;
         compValidate.Operator = ValidationCompareOperator.LessThanEqual;
         compValidate.ErrorMessage = "EndDate should not be less than StartDate"
      }
    }

    Thanks,
    Shinu.
  4. arzie
    arzie avatar
    3 posts
    Member since:
    Apr 2011

    Posted 27 Dec 2012 Link to this post

    thank it works for me...
Back to Top