I have a grid with a GridDateTimeColumn. I do InPlace editing on the grid. I need to validate that the date entered is a valid date. I can't see to determine how to do this. I tried the RequiredFieldValidator, but that doesn't work correctly. If I enter an invalid date, and click the update button, the date field gets the red box around it and the grid goes out of edit mode and reverts rebinds.
How can I flag the invalid date, notify the user the date is invalid and keep the grid in edit mode?
This is my grid.
How can I flag the invalid date, notify the user the date is invalid and keep the grid in edit mode?
This is my grid.
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="Datasource" AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true" ShowFooter="true" Skin="Forest" PageSize="100" OnItemCommand="RadGrid1_ItemCommand" CellSpacing="0" GridLines="None"> <ClientSettings> <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true"></Scrolling> </ClientSettings> <MasterTableView AutoGenerateColumns="false" EditMode="InPlace" DataKeyNames="ID" AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true" DataSourceID="Datasource" CommandItemDisplay="Top"> <CommandItemTemplate> <div style="padding: 5px 5px;"> <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# Not RadGrid1.MasterTableView.IsItemInserted%>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/AddRecord.gif"/>Add new description</asp:LinkButton> <asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Insert.gif"/>Add this description</asp:LinkButton> <asp:LinkButton ID="LinkButton7" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.MasterTableView.IsItemInserted%>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Cancel.gif"/>Cancel</asp:LinkButton> <asp:LinkButton ID="LinkButton1" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count = 0%>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Edit.gif"/>Edit this description</asp:LinkButton> <asp:LinkButton ID="LinkButton5" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0%>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Update.gif"/>Update this description</asp:LinkButton> <asp:LinkButton ID="LinkButton6" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0%>'><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Cancel.gif"/>Cancel</asp:LinkButton> <asp:LinkButton ID="LinkButton8" OnClientClick="javascript:return confirm('Deactivate selected description?')" runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Delete.gif"/>Deactivate selected description</asp:LinkButton> <asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../Images/Refresh.gif"/>Refresh description display</asp:LinkButton> </div> </CommandItemTemplate> <SortExpressions> <telerik:GridSortExpression FieldName="DateHoliday" SortOrder="Ascending" /> </SortExpressions> <Columns> <telerik:GridBoundColumn DataField="ID" UniqueName="ID" Visible="false" ReadOnly="true" /> <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description"/> <telerik:GridDateTimeColumn DataField="DateHoliday" HeaderText="Date of Holiday" UniqueName="DateHoliday" PickerType="DatePicker" DataFormatString="{0:MM/dd/yyyy}" > <ColumnValidationSettings EnableRequiredFieldValidation="true" > <RequiredFieldValidator runat="server" ErrorMessage="Please enter a valid date."></RequiredFieldValidator> </ColumnValidationSettings> </telerik:GridDateTimeColumn> <telerik:GridDateTimeColumn DataField="TimeOpen" HeaderText="Opening time" UniqueName="TimeOpen" PickerType="TimePicker" DataFormatString="{0:t}" /> <telerik:GridDateTimeColumn DataField="TimeClosed" HeaderText="Closing Time" UniqueName="TimeClosed" PickerType="TimePicker" DataFormatString="{0:t}"/> <telerik:GridCheckBoxColumn DataField="Active" UniqueName="Active" HeaderText="Active" /> </Columns> </MasterTableView> <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" /> </ClientSettings> </telerik:RadGrid>