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

validation in grid

1 Answer 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vairam
Top achievements
Rank 1
vairam asked on 02 Jun 2008, 10:41 AM

Hi

While i'm updating the grid i need to validate. when i click the update button it not validating the textbox value here is my code.what i need to do?

<

telerik:RadGrid ID="RadGridRule" runat="server" ValidationSettings-EnableValidation="true" ValidationSettings-ValidationGroup="grid" ValidationSettings-CommandsToValidate="PerformInsert,Update" Skin="Office2007" Width="688px" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" GridLines="None" OnItemCommand="RadGridRule_ItemCommand" OnNeedDataSource="RadGridRule_NeedDataSource" >

<MasterTableView DataKeyNames="RuleId" EditMode="EditForms" CommandItemDisplay="Top" >

<RowIndicatorColumn Visible="False">

<HeaderStyle Width="20px" />

</RowIndicatorColumn>

<ExpandCollapseColumn Resizable="False" Visible="False">

<HeaderStyle Width="20px" />

</ExpandCollapseColumn>

<Columns>

<telerik:GridEditCommandColumn >

</telerik:GridEditCommandColumn>

<telerik:GridBoundColumn DataField="RuleId" UniqueName="RuleID" HeaderText="RuleId" SortExpression="RuleId"

Visible="False" Display="False" ReadOnly="True">

</telerik:GridBoundColumn>

<telerik:GridTemplateColumn HeaderText="Rule Name" SortExpression="RuleName"

UniqueName="RuleName" EditFormColumnIndex="1" Visible="true">

<HeaderStyle Width="150px" />

<ItemTemplate>

<asp:Label runat="server" ID="lblRuleName" Text='<%# Eval("RuleName") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox runat="server" CssClass="textbox" Height="22px" ID="txtRuleName" Text='<%# Bind("RuleName") %>'></asp:TextBox>

<asp:RequiredFieldValidator ID="rfvRuleName" ControlToValidate="txtRuleName" CssClass="errormsg" Display="Dynamic" ErrorMessage="*" ValidationGroup="grid" runat="server" ></asp:RequiredFieldValidator>

</EditItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="Rule Description" SortExpression="RuleDescription"

UniqueName="RuleDescription" EditFormColumnIndex="1" Visible="true">

<HeaderStyle Width="150px" />

<ItemTemplate>

<asp:Label runat="server" ID="lblRuleDescription" Text='<%# Eval("RuleDescription") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox runat="server" CssClass="textbox" MaxLength="1000" TextMode="MultiLine" Height="30px" Width="200px" ID="txtRuleDescription" Text='<%# Bind("RuleDescription") %>'></asp:TextBox>

<br />

</EditItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="Rule Order" SortExpression="RuleOrder"

UniqueName="RuleOrder" EditFormColumnIndex="1" Visible="true">

<HeaderStyle Width="150px" />

<ItemTemplate>

<asp:Label runat="server" ID="lblRuleOrder" Text='<%# Eval("RuleOrder") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<asp:TextBox runat="server" CssClass="textbox" Height="22px" ID="txtRuleOrder" Text='<%# Bind("RuleOrder") %>'></asp:TextBox>

<asp:RequiredFieldValidator ID="rfvRuleOrder" ControlToValidate="txtRuleOrder" CssClass="errormsg" Display="Dynamic" ErrorMessage="*" ValidationGroup="grid" runat="server" ></asp:RequiredFieldValidator>

<asp:RangeValidator ID="rvRuleOrder" ControlToValidate="txtRuleOrder" runat="server" CssClass="errormsg" Display="Dynamic" ErrorMessage="Invalid" Type="Integer" ValidationGroup="grid" MinimumValue="1" MaximumValue="1000"></asp:RangeValidator>

</EditItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="BoundaryMin" SortExpression="BoundaryMin"

UniqueName="BoundaryMin" EditFormColumnIndex="1" Visible="true">

<HeaderStyle Width="150px" />

<ItemTemplate>

<asp:Label runat="server" ID="lblBoundaryMin" Text='<%# Eval("BoundaryMin","{0:C}") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<telerik:RadNumericTextBox Skin="Office2007" ShowSpinButtons="true" Value='<%# (double.Parse(DataBinder.Eval(Container.DataItem, "BoundaryMin")==DBNull.Value ? "0.0" :DataBinder.Eval(Container.DataItem, "BoundaryMin").ToString()))%>' Type="Currency" ID="txtBoundaryMin" NumberFormat-DecimalDigits="2" NumberFormat-AllowRounding="true" NumberFormat-DecimalSeparator="." NumberFormat-GroupSeparator="," NumberFormat-GroupSizes="3" runat="server"></telerik:RadNumericTextBox>

<asp:RequiredFieldValidator ID="rfvBoundaryMin" ControlToValidate="txtBoundaryMin" CssClass="errormsg" Display="Dynamic" ErrorMessage="*" ValidationGroup="grid" runat="server" ></asp:RequiredFieldValidator>

</EditItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn HeaderText="BoundaryMax" SortExpression="BoundaryMax"

UniqueName="BoundaryMax" EditFormColumnIndex="1" Visible="true">

<HeaderStyle Width="150px" />

<ItemTemplate>

<asp:Label runat="server" ID="lblBoundaryMax" Text='<%# Eval("BoundaryMax") %>'></asp:Label>

</ItemTemplate>

<EditItemTemplate>

<telerik:RadNumericTextBox Skin="Office2007" ShowSpinButtons="true" MinValue="1" Value='<%# (double.Parse(DataBinder.Eval(Container.DataItem, "BoundaryMax")==DBNull.Value ? "1.0" :DataBinder.Eval(Container.DataItem, "BoundaryMax").ToString()))%>' Type="Currency" ID="txtBoundaryMax" NumberFormat-DecimalDigits="2" NumberFormat-AllowRounding="true" NumberFormat-DecimalSeparator="." NumberFormat-GroupSeparator="," NumberFormat-GroupSizes="3" runat="server"></telerik:RadNumericTextBox>

<asp:RequiredFieldValidator ID="rfvBoundaryMax" ControlToValidate="txtBoundaryMax" CssClass="errormsg" Display="Dynamic" ErrorMessage="*" ValidationGroup="grid" runat="server" ></asp:RequiredFieldValidator>

<asp:CompareValidator ID ="cvBoundary" ControlToCompare ="txtBoundaryMax" ControlToValidate="txtBoundaryMin" CssClass="BoundaryMin Should be less than or equal to BountryMax" ValidationGroup="grid" Type="Currency" runat="server" Operator="GreaterThanEqual"></asp:CompareValidator>

</EditItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridButtonColumn CommandName="Delete" ConfirmText="Do you want to Remove this Rule?" HeaderText="Remove" Text="Remove" UniqueName="DeleteColumn">

<HeaderStyle HorizontalAlign="Center" />

<ItemStyle HorizontalAlign="Center" />

</telerik:GridButtonColumn>

</Columns>

<EditFormSettings ColumnNumber="2" CaptionDataField="RuleName" CaptionFormatString="Edit properties of Rule {0}">

<FormTableItemStyle Wrap="False"></FormTableItemStyle>

<FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>

<FormMainTableStyle GridLines="Horizontal" CellSpacing="0" CellPadding="3" BackColor="White"

Width="100%" />

<FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px"

BackColor="White" />

<FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>

<EditColumn ButtonType="ImageButton"

InsertText="Insert Rule" UpdateText="Update record" UniqueName="EditCommandColumn1" CancelText="Cancel edit">

</EditColumn>

<FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>

</EditFormSettings>

</MasterTableView>

<ClientSettings>

<Selecting AllowRowSelect="True" />

</ClientSettings>

</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 02 Jun 2008, 11:55 AM
Hi vairam,

To see more information on the validation options with the control, please refer to the following article. Alternatively, you can dynamically nest the validators in the edit form, or use the ItemCommand handler of the control to validate the input on the server.

Greetings,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
vairam
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or