This is a migrated thread and some comments may be shown as answers.

Clinet side validation issue in RadGrid EditFormSettings

1 Answer 170 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ekta agnihotri
Top achievements
Rank 1
ekta agnihotri asked on 24 Dec 2010, 09:31 AM
Hi,
We are facing issues while using the Clinet side validation (RequiredFieldValidator) in RadGrid EditFormSettings section.
The Edit/Add form has a button (btnGrdSave), on click btnGrdSave button the RequiredFieldValidator doesn't gets fired, instead the server side code is executed. This behaviour is causing the server code execution before validating the form.

I am attaching the code, kindly review and help me in sorting out the issue.

Code:
<telerik:RadGrid ID="RadGridAmount" runat="server" GridLines="None" AllowPaging="True"
                                                                        PageSize="5" AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="true"
                                                                        HorizontalAlign="NotSet" AllowMultiRowEdit="false" AllowFilteringByColumn="true"
                                                                        OnItemCommand="RadGridAmount_ItemCommand" Width="100%" AllowMultiRowSelection="False" AllowAutomaticUpdates="True"
                                                                        OnNeedDataSource="RadGridAmount_NeedDataSource" OnPreRender="RadGridAmount_PreRender">
                                                                        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                                                                        <MasterTableView CommandItemDisplay="Bottom" DataKeyNames="RangeID" EditMode="PopUp">
                                                                            <CommandItemSettings ShowAddNewRecordButton="true" />
                                                                            <Columns>
                                                                                <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Select" AllowFiltering="false">
                                                                                    <ItemTemplate>
                                                                                        <asp:CheckBox ID="chkRangeID" runat="server" AutoPostBack="false" />
                                                                                    </ItemTemplate>
                                                                                </telerik:GridTemplateColumn>
                                                                                <telerik:GridBoundColumn UniqueName="RangeID" HeaderText="RangeID" AllowFiltering="false"
                                                                                    DataField="RangeID" Visible="false">
                                                                                </telerik:GridBoundColumn>
                                                                                <telerik:GridBoundColumn FilterControlWidth="105px" HeaderStyle-Width="300px" ItemStyle-Width="300px"
                                                                                    DataField="RangeFrom" HeaderText="RangeFrom" SortExpression="RangeFrom" UniqueName="RangeFrom"
                                                                                    HeaderStyle-Font-Bold="true" ReadOnly="true">
                                                                                </telerik:GridBoundColumn>
                                                                                <telerik:GridBoundColumn FilterControlWidth="105px" HeaderStyle-Width="300px" ItemStyle-Width="300px"
                                                                                    DataField="RangeTo" HeaderText="RangeTo" SortExpression="RangeTo" UniqueName="RangeTo"
                                                                                    HeaderStyle-Font-Bold="true" ReadOnly="true">
                                                                                </telerik:GridBoundColumn>
                                                                                <telerik:GridTemplateColumn HeaderText="Percentege" DataField="Percentege" UniqueName="Percentege"
                                                                                    HeaderStyle-Font-Bold="true" AllowFiltering="false">
                                                                                    <ItemTemplate>
                                                                                        <asp:TextBox ID="txtPercentage" runat="server" Width="30%"></asp:TextBox>
                                                                                    </ItemTemplate>
                                                                                </telerik:GridTemplateColumn>
                                                                                <telerik:GridTemplateColumn HeaderText="Amount" DataField="Amount" UniqueName="Amount"
                                                                                    HeaderStyle-Font-Bold="true" AllowFiltering="false">
                                                                                    <ItemTemplate>
                                                                                        <asp:TextBox ID="txtAmount" runat="server" Width="30%"></asp:TextBox>
                                                                                    </ItemTemplate>
                                                                                </telerik:GridTemplateColumn>
                                                                                <telerik:GridEditCommandColumn>
                                                                                </telerik:GridEditCommandColumn>
                                                                                <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete">
                                                                                </telerik:GridButtonColumn>
                                                                            </Columns>
                                                                            <EditFormSettings InsertCaption="Add new item" CaptionFormatString="Edit RangeID: {0}"
                                                                                CaptionDataField="RangeID" EditFormType="Template">
                                                                                <FormTemplate>
                                                                                    <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0">
                                                                                        <tr>
                                                                                            <td>
                                                                                            </td>
                                                                                            <td>
                                                                                            </td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td>
                                                                                                Range From:
                                                                                            </td>
                                                                                            <td>
                                                                                                <asp:TextBox ID="txtRangeFrom" Text='<%# Bind("RangeFrom") %>' runat="server" ValidationGroup="RangeValidation1">
                                                                                                </asp:TextBox>
                                                                                                  <asp:RequiredFieldValidator runat="server" ID="rfvFrom" ControlToValidate="txtRangeFrom"
                                                                                                    Display="Dynamic" ErrorMessage="Range From is required" ValidationGroup="RangeValidation1" />
                                                                                           
                                                                                            </td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                            <td>
                                                                                                Range To:
                                                                                            </td>
                                                                                            <td>
                                                                                                <asp:TextBox ID="txtRangeTo" Text='<%# Bind("RangeTo") %>' runat="server" ValidationGroup="RangeValidation1">1
                                                                                                </asp:TextBox>
                                                                                                  <asp:RequiredFieldValidator runat="server" ID="rfvTo" ControlToValidate="txtRangeTo"
                                                                                                    Display="Dynamic" ErrorMessage="Range To is required" ValidationGroup="RangeValidation1" />
                                                                                           
                                                                                            </td>
                                                                                        </tr>
                                                                                    </table>
                                                                                    <table style="width: 100%">
                                                                                        <tr>
                                                                                            <td align="right" colspan="2">
                                                                                                <asp:Button ID="btnGrdSave" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                                                                    ValidationGroup="RangeValidation1" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                                                                                </asp:Button>&nbsp;
                                                                                                <asp:Button ID="btnGrdCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                                                                    CommandName="Cancel"></asp:Button>
                                                                                                <asp:ValidationSummary ID="valsumm" runat="server" ValidationGroup="RangeValidation1" ShowSummary="true">
                                                                                                </asp:ValidationSummary>
                                                                                            </td>
                                                                                        </tr>
                                                                                    </table>
                                                                                </FormTemplate>
                                                                            </EditFormSettings>
                                                                        </MasterTableView>
                                                                    </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 28 Dec 2010, 09:12 AM
Hello Ekta,

It seems to me that validation is working properly. For your convenience I am attaching sample page.

Best wishes,
Nikolay
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
ekta agnihotri
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or