Hi
I have been trying to follow the example http://www.telerik.com/help/aspnet-ajax/grdvalidation.html to add a requiredfield validator to a GridTimeDateColumn by changing the GridTextBoxColumnEditor to a GridDateTimeColumnEditor but this does not seem to work.
When I try to insert a new record I get the error Object reference not set to an instance of an object.
Here is my markup
And Code
Does anyone know what the problem could be.
Regards
Mike
I have been trying to follow the example http://www.telerik.com/help/aspnet-ajax/grdvalidation.html to add a requiredfield validator to a GridTimeDateColumn by changing the GridTextBoxColumnEditor to a GridDateTimeColumnEditor but this does not seem to work.
When I try to insert a new record I get the error Object reference not set to an instance of an object.
Here is my markup
<form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RiskGrid_NeedDataSource" OnItemCreated="RiskGrid_ItemCreated"> <MasterTableView commanditemdisplay="Bottom"> <Columns> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> <HeaderStyle Width="2%" /> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> </Columns> </MasterTableView> </telerik:RadGrid> </div> </form>And Code
protected void RiskGrid_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem item = e.Item as GridEditableItem; GridDateTimeColumnEditor editor = (GridDateTimeColumnEditor)item.EditManager.GetColumnEditor("DateReported"); TableCell cell = (TableCell)editor.PickerControl.Parent; RequiredFieldValidator validator = new RequiredFieldValidator(); editor.PickerControl.ID = "rdpDateRecorded"; validator.ControlToValidate = editor.PickerControl.ID; validator.ErrorMessage = "*"; cell.Controls.Add(validator); } }Does anyone know what the problem could be.
Regards
Mike