hi all,
i have a GridDateTimeColumn in a grid, i added compare validators for it in the code like the example here http://www.telerik.com/help/aspnet-ajax/grdvalidation.html, one to check the type, and another to compare it with Date.Now
the problem is that the validator that checks the type works only on insert but not on update! i can't find any logical reason for that..here is my code
"compareValidator1" is the one that is not working on update, when i enter string characters in the date field and click on update button it performs updating process, it considers the page as valid
Any ideas?? wht am i doing wrong??
thnx in advance
i have a GridDateTimeColumn in a grid, i added compare validators for it in the code like the example here http://www.telerik.com/help/aspnet-ajax/grdvalidation.html, one to check the type, and another to compare it with Date.Now
the problem is that the validator that checks the type works only on insert but not on update! i can't find any logical reason for that..here is my code
<telerik:GridDateTimeColumn HeaderText="Start Date" SortExpression="startDate" UniqueName="startDate" AutoPostBackOnFilter="true" DataField="startDate" |
FilterControlWidth="110px" PickerType="DatePicker" DataFormatString="{0:d/M/yyyy}" DataType="System.DateTime"> |
</telerik:GridDateTimeColumn> |
Private Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated |
If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then |
Dim item As GridEditableItem = CType(e.Item, GridEditableItem) |
Dim startColumnEditor As GridDateTimeColumnEditor = TryCast(DirectCast(e.Item, GridEditableItem).EditManager.GetColumnEditor("startDate"), GridDateTimeColumnEditor) |
Dim startCell As TableCell = DirectCast(startColumnEditor.PickerControl.Parent, TableCell) |
Dim compareValidator1 As New CompareValidator() |
compareValidator1.ID = "compareValidator1" |
compareValidator1.ControlToValidate = startColumnEditor.PickerControl.ID |
compareValidator1.[Operator] = ValidationCompareOperator.DataTypeCheck |
compareValidator1.Type = ValidationDataType.[Date] |
compareValidator1.ErrorMessage = "Invalid date. " |
compareValidator1.Display = ValidatorDisplay.Dynamic |
startCell.Controls.Add(compareValidator1) |
Dim compareValidator3 As New CompareValidator() |
compareValidator3.ID = "compareValidator3" |
compareValidator3.ControlToValidate = startColumnEditor.PickerControl.ID |
compareValidator3.[Operator] = ValidationCompareOperator.GreaterThanEqual |
compareValidator3.Type = ValidationDataType.[Date] |
compareValidator3.ErrorMessage = "Date can't be earlier than today" |
compareValidator3.ValueToCompare = DateTime.Now.ToShortDateString() |
compareValidator3.Display = ValidatorDisplay.Dynamic |
startCell.Controls.Add(compareValidator3) |
End If |
End Sub |
Private Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand |
If e.CommandName = "Update" Then |
If Page.IsValid Then |
e.Item.Edit = False |
End If |
ElseIf e.CommandName = "PerformInsert" Then |
If Page.IsValid Then |
e.Canceled = True |
e.Item.OwnerTableView.IsItemInserted = False |
e.Item.OwnerTableView.Rebind() |
End If |
ElseIf e.CommandName = "Delete" Then |
End If |
End Sub |
"compareValidator1" is the one that is not working on update, when i enter string characters in the date field and click on update button it performs updating process, it considers the page as valid
Any ideas?? wht am i doing wrong??
thnx in advance