i am making a page where i need some validation that StartDate should be
less than the EndDate and i m using telerik:GridDateTimeColumn. Please
tell me hoe can i compare these two values from
telerik:GridDateTimeColumn.
its ergent please.....:-/
Can anyone please help me in this regard......
its ergent please.....:-/
Can anyone please help me in this regard......
5 Answers, 1 is accepted
0
Accepted

Princy
Top achievements
Rank 2
answered on 09 Aug 2012, 08:15 AM
Hi Muhammad,
Try the following code to compare dates in GridDateTimeColumn.
C#:
Hope this helps.
Regards,
Princy.
Try the following code to compare dates in GridDateTimeColumn.
C#:
protected
void
Rdagrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem eitem = (GridEditableItem)e.Item;
RadDatePicker RadDatePicker1 = (RadDatePicker)eitem[
"UniqueName1"
].Controls[0];
RadDatePicker RadDatePicker2 = (RadDatePicker)eitem[
"UniqueName2"
].Controls[0];
CompareValidator compareValidator =
new
CompareValidator();
compareValidator.ID =
"compareValidator"
;
compareValidator.ControlToValidate = RadDatePicker1.ID;
compareValidator.ControlToCompare = RadDatePicker2.ID;
compareValidator.Operator = ValidationCompareOperator.GreaterThanEqual;
compareValidator.Type = ValidationDataType.Date;
compareValidator.ErrorMessage =
"*"
;
eitem[
"UniqueName1"
].Controls.Add(compareValidator);
}
}
Hope this helps.
Regards,
Princy.
0

Muhammad
Top achievements
Rank 1
answered on 09 Aug 2012, 10:50 AM
the other thing is DropdownColumn where i want to set semester status ("Open for Registration","In Progress","Closed") where only one semester can be in "In Progress" State how can i get the status in CustomValidator to set the args value true or false?
0

Muhammad
Top achievements
Rank 1
answered on 09 Aug 2012, 10:51 AM
it works as my requirements thanks for help...
May God bless you...:-)
May God bless you...:-)
0

Kjell
Top achievements
Rank 1
Iron
Iron
answered on 23 Sep 2013, 09:55 AM
Hi
I am using 2 telerik:GridDateTimeColumn. startdatum and sludatum
I have convert the C# code using converter.telerik.com to VB, but the validate not works....
Nothing happens.
I am using 2 telerik:GridDateTimeColumn. startdatum and sludatum
I have convert the C# code using converter.telerik.com to VB, but the validate not works....
Nothing happens.
If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
Dim eitem As GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim RadDatePicker1 As RadDatePicker = DirectCast(eitem("startdatum").Controls(0), RadDatePicker)
Dim RadDatePicker2 As RadDatePicker = DirectCast(eitem("slutdatum").Controls(0), RadDatePicker)
Dim compareValidator As New CompareValidator()
compareValidator.ID = "compareValidator"
compareValidator.ControlToValidate = RadDatePicker1.ID
compareValidator.ControlToCompare = RadDatePicker2.ID
compareValidator.[Operator] = ValidationCompareOperator.GreaterThanEqual
compareValidator.Type = ValidationDataType.[Date]
compareValidator.ErrorMessage = "*"
eitem("startdatum").Controls.Add(compareValidator)
End If
0

Princy
Top achievements
Rank 2
answered on 23 Sep 2013, 10:23 AM
Hi ,
Please try the following code snippet to Compare two GridDateTimeColumn.
VB:
Thanks,
Princy
Please try the following code snippet to Compare two GridDateTimeColumn.
VB:
Protected
Sub
RadGrid1_ItemCreated(sender
As
Object
, e
As
GridItemEventArgs)
If
TypeOf
e.Item
Is
GridEditableItem
AndAlso
e.Item.IsInEditMode
Then
Dim
item
As
GridEditableItem = TryCast(e.Item, GridEditableItem)
Dim
start
As
RadDatePicker =
DirectCast
(item(
"ColumnUniqueName1"
).Controls(0), RadDatePicker)
Dim
[end]
As
RadDatePicker =
DirectCast
(item(
"ColumnUniqueName2"
).Controls(0), RadDatePicker)
Dim
cell
As
TableCell =
DirectCast
(start.Parent, TableCell)
Dim
val
As
New
CompareValidator()
val.ControlToCompare = start.ID
val.ControlToValidate = [end].ID
val.[Operator] = ValidationCompareOperator.GreaterThanEqual
val.ErrorMessage =
"Error message"
val.ForeColor = Color.Red
cell.Controls.Add(val)
End
If
End
Sub
Thanks,
Princy