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

Percent validation

2 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
Iron
Iron
Veteran
David asked on 26 Dec 2014, 09:21 PM
Hi, I have a grid which is setup as batch edit. One of the columns defined the following way:

 <telerik:GridTemplateColumn HeaderText="% Local" HeaderStyle-Width="50px" SortExpression="LPC" UniqueName="LPC"
                                                DataField="LPC">
                        <ItemTemplate>
                            <asp:Label runat="server" ID="lblLPC" Text='<%# Eval("LPC", "{0:P2}") %>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <span>
                                <telerik:RadNumericTextBox ID="tbLPC" Width="50px" runat="server">
                                </telerik:RadNumericTextBox>
                                <span style="color: Red">
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                                        ControlToValidate="tbLPC" ErrorMessage="*" runat="server" Display="Dynamic"
                                        ToolTip="Required"
                                        style="color:Red;font-size:30px; font-weight:bold;">
                                    </asp:RequiredFieldValidator>
                                    <asp:RangeValidator ID="rvtbLPC" runat="server"
                                                ControlToValidate="tbLPC" ToolTip="Must be numeric value between 0 and 1"
                                                ErrorMessage="*" style="color:Red;font-size:30px; font-weight:bold;"
                                                MinimumValue="0" MaximumValue="1" Display="Dynamic">
                                    </asp:RangeValidator>
                                </span>
                            </span>
                        </EditItemTemplate>
                    </telerik:GridTemplateColumn>

Validation always think that field is invalid. I even tried to increase MaximumValue to 100.
Please

2 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 29 Dec 2014, 08:45 AM
Hi David,

I have tested your GridTemplateColumn with RadGrid in Batch edit mode and the validation is working correctly if the entered value is between 0 and 1. 

Can you please elaborate what version of the controls you are using and if you have some custom logic that could interfere with the validation.

Following is the example that I have tested locally:
<telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView AutoGenerateColumns="false" EditMode="Batch">
        <Columns>
            <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
            <telerik:GridTemplateColumn HeaderText="% Local" HeaderStyle-Width="350px" SortExpression="LPC" UniqueName="LPC"
                DataField="LPC">
                <ItemTemplate>
                    <asp:Label runat="server" ID="lblLPC" Text='<%# Eval("LPC", "{0:P2}") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <span>
                        <telerik:RadNumericTextBox ID="tbLPC" Width="50px" runat="server">
                        </telerik:RadNumericTextBox>
                        <span style="color: Red">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
                                ControlToValidate="tbLPC" ErrorMessage="*" runat="server" Display="Dynamic"
                                ToolTip="Required"
                                Style="color: Red; font-size: 30px; font-weight: bold;">
                            </asp:RequiredFieldValidator>
                            <asp:RangeValidator ID="rvtbLPC" runat="server"
                                ControlToValidate="tbLPC" ToolTip="Must be numeric value between 0 and 1"
                                ErrorMessage="*" Style="color: Red; font-size: 30px; font-weight: bold;"
                                MinimumValue="0" MaximumValue="1" Display="Dynamic">
                            </asp:RangeValidator>
                        </span>
                    </span>
                </EditItemTemplate>
            </telerik:GridTemplateColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

And the code-behind:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DataTable table = new DataTable();
    table.Columns.Add("ID", typeof(int));
    table.Columns.Add("LPC", typeof(decimal));
    for (int i = 1; i < 5; i++)
    {
        table.Rows.Add(i, 0.007);
    }
 
    (sender as RadGrid).DataSource = table;
}


Best Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
David
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 29 Dec 2014, 02:16 PM
Thank you Konstantin.
I might test your approach later, for now i solved it by using Minimum and Maximum values of RadNumericTextBox itself
Tags
Grid
Asked by
David
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Konstantin Dikov
Telerik team
David
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or