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

Grid with Validation issue

2 Answers 76 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 14 Jun 2013, 05:21 PM
I have a rad grid with ADD/Update all working correctly.  Above the grid on the I have a select box and date picker that is used in filtering the data that is bound to my grid.

I added a RequiredFieldValidator to two of the column columns.

If I change the select box above the grid and rebind the grid while the user is in "Add" mode, the Validator is triggered and the grid stays in add mode...


Is there a way to force the grid to refresh and not be left in add mode from the validation.  If I take out the field validation, then all works as expected.

<telerik:GridTemplateColumn DataField="sFirstName"
            FilterControlAltText="Filter sFirstName column" HeaderText="First Name"
            SortExpression="sFirstName" UniqueName="sFirstName">
            <EditItemTemplate>
                <asp:TextBox ID="sFirstNameTextBox" runat="server" Text='<%# Bind("sFirstName") %>' MaxLength="50"></asp:TextBox>
 
                <asp:RequiredFieldValidator ID="rfvFirstName" ControlToValidate="sFirstNameTextBox"
                    ErrorMessage="*Required" Display="Static" runat="server" ForeColor="Red">
                </asp:RequiredFieldValidator>
 
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="sFirstNameLabel" runat="server" Text='<%# Eval("sFirstName") %>'></asp:Label>
            </ItemTemplate>
        </telerik:GridTemplateColumn>      





2 Answers, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 1
answered on 14 Jun 2013, 05:39 PM
Here is a little more that might help.

    <asp:Label ID="lblSite" runat="server" Text="Site"></asp:Label>
    <telerik:RadDropDownList ID="ddlSite" runat="server" AutoPostBack="True"  DataTextField="Facility"
                DataValueField="Facility_ID" Width="450px">
    </telerik:RadDropDownList>
    <asp:Label ID="lblDOS" runat="server" Text="DOS"></asp:Label>
    <telerik:RadDatePicker ID="dpDOS" runat="server" AutoPostBack="True"
        MinDate="2013-06-01" Width="150px">
    </telerik:RadDatePicker>
     
     
 <telerik:RadGrid ID="gvPatientList" runat="server" CellSpacing="0"
        DataSourceID="dsPatientList" GridLines="None" AutoGenerateColumns="False"
<MasterTableView DataSourceID="dsPatientList" DataKeyNames="PatientID" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" CommandItemDisplay="Top" RetrieveNullAsDBNull ="True">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
 
    <Columns>  
 <telerik:GridTemplateColumn DataField="sFirstName"
            FilterControlAltText="Filter sFirstName column" HeaderText="First Name"
            SortExpression="sFirstName" UniqueName="sFirstName">
            <EditItemTemplate>
                <asp:TextBox ID="sFirstNameTextBox" runat="server" Text='<%# Bind("sFirstName") %>' MaxLength="50"></asp:TextBox>
 
                <%--<asp:RequiredFieldValidator ID="rfvFirstName" ControlToValidate="sFirstNameTextBox"
                    ErrorMessage="*Required" Display="Static" runat="server" ForeColor="Red">
                </asp:RequiredFieldValidator>--%>
 
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="sFirstNameLabel" runat="server" Text='<%# Eval("sFirstName") %>'></asp:Label>
            </ItemTemplate>
        </telerik:GridTemplateColumn>  
    </Columns>
</MasterTableView>
</telerik:RadGrid
    
0
Kostadin
Telerik team
answered on 19 Jun 2013, 11:28 AM
Hi Ryan,

A possible solution is to set MasterTableView's IsItemInserted property to false and rebind the grid. This way the insert form will be closed. Check out the following code snippet.
RadGrid1.MasterTableView.IsItemInserted = false;

Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 1
Kostadin
Telerik team
Share this question
or