I have been adding validation to a RadGrid, whenever i try to add any Validation groups it causes the RequiredFieldValidator to not work at all
Is there any work around for this? I would like to have a summary of errors listed
Is there any work around for this? I would like to have a summary of errors listed
<telerik:RadGrid ID="RadGrid2" runat="server" Width="100%" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True" AllowMultiRowEdit="false" AllowMultiRowSelection="false" AutoGenerateColumns="False" DataSourceID="SqlDataSource2" EnableLinqExpressions="false" GridLines="None" OnItemCreated="RadGrid2_ItemCreated" OnItemDataBound="RadGrid2_ItemDataBound" OnItemUpdated="RadGrid2_ItemUpdated" OnItemInserted="RadGrid2_ItemInserted" OnDataBound="RadGrid2_DataBound" OnItemCommand="RadGrid2_ItemCommand" OnPreRender="RadGrid2_PreRender"> <PagerStyle Mode="NextPrevAndNumeric" /> <MasterTableView Width="100%" CommandItemDisplay="Bottom" EditMode="InPlace" DataSourceID="SqlDataSource2" HorizontalAlign="NotSet" AutoGenerateColumns="false"> <Columns> <telerik:GridBoundColumn DataField="ProductTypeId" HeaderText="ProductTypeId" SortExpression="ProductTypeId" UniqueName="ProductTypeId" Visible="false"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="ProductAttributeDefKeyOri" HeaderText="ProductAttributeDefKeyOri" SortExpression="ProductAttributeDefKeyOri" UniqueName="ProductAttributeDefKeyOri" Visible="false"> </telerik:GridBoundColumn> <telerik:GridDropDownColumn ListTextField="Name" ListValueField="ProductAttributeDefKey" DataSourceID="SqlDataSource3" HeaderText="Attribute" DataField="ProductAttributeDefKey" UniqueName="ProductAttributeDefKey" DropDownControlType="DropDownList" EnableEmptyListItem="true" EmptyListItemText="Select an attribute..." EmptyListItemValue=""> </telerik:GridDropDownColumn> <telerik:GridTemplateColumn DefaultInsertValue="1" DataField="SortOrder" HeaderText="Sort Order" SortExpression="SortOrder" UniqueName="SortOrder" ForceExtractValue="Always" > <EditItemTemplate> <telerik:RadNumericTextBox runat="server" ID="tbSortOrder" DbValue='<%# Bind("SortOrder") %>' ShowSpinButtons="true" SpinDownCssClass="" SpinUpCssClass="" Width="50px" MinValue="1" MaxValue="999" NumberFormat-DecimalDigits="0" CssClass="textbox_increment"> </telerik:RadNumericTextBox> <asp:RequiredFieldValidator runat="server" ControlToValidate="tbSortOrder" ErrorMessage="*" ValidationGroup="grid2"></asp:RequiredFieldValidator> </EditItemTemplate> <ItemTemplate> <%# Eval("SortOrder")%> </ItemTemplate> <ItemStyle CssClass="MyImageButton" /> </telerik:GridTemplateColumn> <telerik:GridCheckBoxColumn DataField="Enabled" HeaderText="Enabled" SortExpression="Enabled" UniqueName="Enabled" DefaultInsertValue="Checked" > </telerik:GridCheckBoxColumn> <telerik:GridCheckBoxColumn DataField="Required" HeaderText="Required" SortExpression="Required" UniqueName="Required" DefaultInsertValue="1"> </telerik:GridCheckBoxColumn> <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> <ItemStyle CssClass="MyImageButton" /> </telerik:GridEditCommandColumn> </Columns> <EditFormSettings ColumnNumber="2" CaptionFormatString="Edit Attribute" InsertCaption="Add Attribute"> <FormTableItemStyle Wrap="true"></FormTableItemStyle> <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="0" BackColor="White" Width="100%" /> <FormTableStyle CellSpacing="0" CellPadding="1" BackColor="White" /> <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> <PopUpSettings Modal="true" /> <EditColumn ButtonType="ImageButton" InsertText="Add Attribute" UpdateText="Update Attribute" UniqueName="EditCommandColumn1" CancelText="Cancel Edit"></EditColumn> <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> </EditFormSettings> <CommandItemSettings AddNewRecordText="Add Attribute" /> </MasterTableView> </telerik:RadGrid>protected void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { //attribute validation GridEditableItem item = e.Item as GridEditableItem; DropDownList dropDownList1 = item["ProductAttributeDefKey"].Controls[0] as DropDownList; GridDropDownColumnEditor editor = (GridDropDownColumnEditor)item.EditManager.GetColumnEditor("ProductAttributeDefKey"); TableCell cell = (TableCell)editor.ContainerControl; RequiredFieldValidator validator = new RequiredFieldValidator(); validator.ControlToValidate = dropDownList1.ID; validator.ErrorMessage = "*"; validator.ValidationGroup = "grid2"; cell.Controls.Add(validator); } if (e.Item is GridEditableItem && e.Item.IsInEditMode) { if (e.Item.OwnerTableView.IsItemInserted) { //set required and enabled default values for inserting GridEditableItem edititem = (GridEditableItem)e.Item; CheckBox chkbx = (CheckBox)edititem["Enabled"].Controls[0]; chkbx.Checked = true; chkbx = (CheckBox)edititem["Required"].Controls[0]; chkbx.Checked = true; } } }