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

How to validate control in radgrid control if checkbox in radgrid is checked than validate other control

1 Answer 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pankaj
Top achievements
Rank 1
pankaj asked on 06 Oct 2008, 05:23 PM

Hi,

 I have one problem when validating controls in client side, Suppose i have four controls in formtemplate in radgrid control..
If anyone checked the checkbox that is also exist in the radgrid control i have to apply the validation on other controls that is also exist in the raddgrid control.

Please give me the solution how to validate the controls value at client side while one of control has favourable value, otherwise do not apply the validation.

In my form CheckBox like ::
<asp:CheckBox id="CheckBoxIsActive" TabIndex="21" runat="server" Width="150px" Text="Active User"></asp:CheckBox>
if this check box is checked
than i have to validate the following controls

 

asp

:TextBox id="TextBoxUser_Name" TabIndex="18" MaxLength ="256" runat="server" Width="150px"></asp:TextBox>

 

 

 

<

asp:RequiredFieldValidator ID="RequiredFieldValidatorUserName" Display="None" ValidationGroup="Check" runat="server" ControlToValidate="TextBoxUser_Name"

 

 

 

 

ErrorMessage="Please enter user name" ></asp:RequiredFieldValidator>

Kindly give me the solution how to validate the control if checkbox is valid.







 

<

telerik:RadGrid ID="rgStaffPersonDetails" GridLines="None" EnableAJAX="True" runat="server" Skin ="WebBlue" width="100%"

 

 

 

 

AutoGenerateDeleteColumn ="True" AutoGenerateEditColumn ="True" AutoGenerateColumns="false"

 

 

OnItemCommand="rgStaffPersonDetails_ItemCommand" OnItemDataBound="rgStaffPersonDetails_ItemDataBound" OnInit="rgStaffPersonDetails_Init"

 

 

OnInsertCommand="rgStaffPersonDetails_InsertCommand" OnUpdateCommand="rgStaffPersonDetails_UpdateCommand" OnItemCreated="rgStaffPersonDetails_ItemCreated" >

 

 

 

 

<PagerStyle Mode="NumericPages"></PagerStyle>

 

 

 

 

<MasterTableView CommandItemDisplay= "Top" DataKeyNames="Staff_Per_ID" >

 

<

Columns >

 

 

 

 

<telerik:GridBoundColumn DataField="Staff_Per_ID" Visible="False" DataType="System.Int32" HeaderText="Per_ID"

 

 

 

 

SortExpression="Per_ID" UniqueName="Per_ID">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Person Name" UniqueName="StaffName">

 

<

ItemTemplate>

 

 

 

 

<asp:Label ID="lblStaffName" runat="server" Text='<%# Eval("Staff_Per_IDSource.Per_FirstName")+" "+Eval("Staff_Per_IDSource.Per_MiddleName")+" "+Eval("Staff_Per_IDSource.Per_LastName")%>'></asp:Label>

 

 

 

 

 

 

</

ItemTemplate>

 

</

telerik:GridTemplateColumn>

 

 

 

 

<telerik:GridTemplateColumn UniqueName="Per_HomePhone" HeaderText="Home Phone">

 

<

ItemTemplate>

 

 

<asp:Label ID="lblPer_CellPhone" runat="server" Text='<%# (Eval("Staff_Per_IDSource.Per_HomePhone") == "") ? "N/A" : String.Format("{0:(###) ###-####}", Eval("Staff_Per_IDSource.Per_HomePhone"))%>'></asp:Label>

 

</

ItemTemplate>

 

</

telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn UniqueName="Per_WorkPhone" HeaderText="Work Phone">

 

<

ItemTemplate>

 

 

<asp:Label ID="lblworkphone" runat="server" Text='<%# (Eval("Staff_Per_IDSource.Per_WorkPhone") == "") ? "N/A" : String.Format("{0:(###) ###-####}", Eval("Staff_Per_IDSource.Per_WorkPhone"))%>'></asp:Label>

 

</

ItemTemplate>

 

</

telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn UniqueName="Per_CellPhone" HeaderText="Cell Phone">

 

<

ItemTemplate>

 

 

<asp:Label ID="lblCellphone" runat="server" Text='<%# (Eval("Staff_Per_IDSource.Per_CellPhone") == "") ? "N/A" : String.Format("{0:(###) ###-####}", Eval("Staff_Per_IDSource.Per_CellPhone"))%>'></asp:Label>

 

 

 

 

 

 

</

ItemTemplate>

 

</

telerik:GridTemplateColumn>

 

 

<telerik:gridtemplatecolumn UniqueName="username" HeaderText="User Name">

 

<

itemtemplate>

 

 

 

 

<asp:label id="lblusername" runat="server" text='<%# Eval("Staff_User_IDSource.UserName") %>'></asp:label>

 

 

 

 

 

 

</

itemtemplate>

 

</

telerik:gridtemplatecolumn>

 

 

 

</

Columns>

 

 

 

 

 

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

 

 

 

 

<HeaderStyle Width="20px" />

 

 

 

 

</ExpandCollapseColumn>

 

 

 

 

<EditFormSettings EditFormType="Template">

 

 

 

 

<PopUpSettings ScrollBars="None" />

 

 

<FormTemplate >

 

 

 

 

<table id="Table2" cellspacing="2" cellpadding="1" width="70%" border="1" rules="none"

 

 

 

 

style="BORDER-COLLAPSE: collapse">

 

 

 

 

<tr class="EditFormHeader">

 

 

 

 

<td colspan="2"><b>Staff Person Detail</b></td>

 

 

 

 

</tr>

 

 

<tr>

 

 

 

 

<td>

 

 

 

 

<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">

 

 

 

 

<tr>

 

 

 

 

<td align ="right" style="width: 15%;">First Name:</td>

 

 

 

 

<td style=" width: 15%;"> <telerik:RadTextBox id="TextBoxFirst_Name" MaxLength ="40" TabIndex="1" Width="150px" runat="server" >

 

 

 

 

</telerik:RadTextBox><asp:RequiredFieldValidator ID="RequiredFieldValidatorFirst_Name" runat="server" Display="None" ValidationGroup="Check" ControlToValidate="TextBoxFirst_Name"

 

 

 

 

ErrorMessage="Please enter first name" ></asp:RequiredFieldValidator>

 

 

 

 

</td>

 

 

 

 

 

</tr>

 

 

 

 

 

 

 

 

 

<tr>

 

 

 

 

<td align ="right" style="width: 15%;" valign="middle">UserName:

 

 

</td>

 

 

 

 

<td style="width: 15%;" valign="middle"><asp:TextBox id="TextBoxUser_Name" TabIndex="18" MaxLength ="256" runat="server" Width="150px"

 

 

 

 

></asp:TextBox>

 

 

 

 

</td>

 

 

 

 

<td align ="right" style="width: 15%;" valign="middle">Password:

 

 

</td>

 

 

 

 

<td style="width: 20%;" valign="middle"><opp:PasswordTextBox id="TextBoxPassword" runat="server" TabIndex="19" />&nbsp;

 

 

 

 

</td>

 

 

 

 

<td align ="right" style="width: 20%;" valign="middle">

 

 

 

Re-Enter:

&nbsp;

 

 

 

 

</td>

 

 

 

 

<td style="width: 20%;" valign="middle"><opp:PasswordTextBox id="TextBoxRePassword" runat="server" TabIndex="20" />&nbsp; &nbsp;

 

 

 

 

</td>

 

 

 

 

</tr>

 

 

 

 

<tr>

 

 

 

 

<td align="right" style="width: 15%; height: 25px;" valign="top">

 

 

 

 

</td>

 

 

 

 

<td style="width: 15%; height: 25px;" valign="top">

 

 

 

 

<asp:CheckBox id="CheckBoxIsActive" TabIndex="21" runat="server" Width="150px" Text="Active User"></asp:CheckBox></td>

 

 

 

 

<td align="right" style="width: 15%; height: 25px;" valign="top">

 

 

 

 

</td>

 

 

 

 

<td style="width: 20%; height: 25px;" valign="top">

 

 

 

 

</td>

 

 

 

 

<td align="right" style="width: 20%; height: 25px;" valign="top">

 

 

 

 

</td>

 

 

 

 

<td style="width: 20%; height: 25px;" valign="top">

 

 

 

 

<asp:RequiredFieldValidator ID="ReqTextBoxRePassword" runat="server" ControlToValidate="TextBoxRePassword" ValidationGroup="Check" Display="None" ErrorMessage="Please Re-Enter Password"></asp:RequiredFieldValidator></td>

 

 

 

 

</tr>

 

 

 

 

<tr>

 

 

 

 

<td align ="right" style="width: 15%;">

 

 

 

 

</td>

 

 

 

 

<td style="width: 15%;">

 

 

 

 

 

<asp:RequiredFieldValidator ID="RequiredFieldValidatorUserName" Display="None" ValidationGroup="Check" runat="server" ControlToValidate="TextBoxUser_Name"

 

 

 

 

ErrorMessage="Please enter user name" ></asp:RequiredFieldValidator></td>

 

 

<td align="left" colspan="2"><asp:ValidationSummary ID="ValidationSummary2" runat="server" ValidationGroup="Check" DisplayMode ="BulletList" Width="100%" />

 

 

<asp:CompareValidator ID="CompareValidatorPassword" runat="server"

 

 

 

 

ErrorMessage="Please enter same password" ValidationGroup="Check" ControlToCompare="TextBoxPassword" ControlToValidate="TextBoxRePassword" Display="None"></asp:CompareValidator>

 

 

 

 

<asp:RequiredFieldValidator ID="ReqTextBoxPassword" ControlToValidate="TextBoxPassword" ValidationGroup="Check" runat="server" Display="None" ErrorMessage="Please enter Password"></asp:RequiredFieldValidator></td>

 

 

 

 

</tr>

 

 

 

 

</table>

 

 

 

 

</td>

 

 

 

 

</tr>

 

 

<tr>

 

 

 

 

<td align="right" colspan="2"><asp:Button id="cmdButton" ValidationGroup="Check" runat="server" Text='Update' TabIndex="23" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>'>

 

 

 

 

</asp:Button></td><td><asp:Button id="btnCancel" runat="server" Text="Cancel" TabIndex="24" CausesValidation="False" CommandName="Cancel">

 

 

 

 

</asp:Button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>

 

 

 

 

</tr>

 

</

table>

 

 

</FormTemplate>

 

 

 

 

<EditColumn UniqueName="EditCommandColumn1">

 

 

 

 

</EditColumn>

 

 

 

 

</EditFormSettings>

 

 

 

 

<RowIndicatorColumn Visible="False">

 

 

 

 

<HeaderStyle Width="20px" />

 

 

 

 

</RowIndicatorColumn>

 

</

MasterTableView>

 

 

</telerik:RadGrid>

 

 


Please give me the solutuion either javascript ofr any other way, Actually i am using this grid in the usercontrol that's what i am unable to get the control's Id at runtime as matched.
 

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 09 Oct 2008, 07:29 AM
Hello pankaj,

The flexible validation mechanism of RadGrid is demonstrated in the following online resources:

http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/DataEditing/Validation/DefaultVB.aspx
http://www.telerik.com/help/aspnet-ajax/grdvalidation.html

Feel free to utilize the logic presented their for your custom case in order to attain the validation functionality you are after.

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
pankaj
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or