This is a migrated thread and some comments may be shown as answers.

Compare Datetime

3 Answers 48 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
arzie
Top achievements
Rank 1
arzie asked on 26 Dec 2012, 12:51 PM
who compare datetime in radgrid itemdatabound? , please help

3 Answers, 1 is accepted

Sort by
0
rdmptn
Top achievements
Rank 1
answered on 26 Dec 2012, 04:48 PM
0
Shinu
Top achievements
Rank 2
answered on 27 Dec 2012, 04:15 AM
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.
0
arzie
Top achievements
Rank 1
answered on 27 Dec 2012, 07:13 AM
thank it works for me...
Tags
General Discussions
Asked by
arzie
Top achievements
Rank 1
Answers by
rdmptn
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
arzie
Top achievements
Rank 1
Share this question
or