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

[Solved] Validating RadTreeView inside a RadGrid

5 Answers 261 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Giblin
Top achievements
Rank 1
John Giblin asked on 20 Mar 2009, 03:15 PM
I have a Rad Grid that has a RadTreeView inside the FormTemplate.  I am unable to add a required field for that control. I get:

Control 'TreeViewApplicationType2' referenced by the ControlToValidate property of 'RequiredFieldValidator2' cannot be validated.



I also tried a custom validation which also didnt work.  Any ideas?. I am using  q2 2008

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Mar 2009, 06:18 AM

Hi John,

I tried adding RequireFiieldValidator for RadTreeView which is placed inside RadGrid as FormTemplate and its working fine for me. Check the following ASPX:

<EditFormSettings  EditFormType="Template">  
<FormTemplate> 
<telerik:RadTreeView ID="RadTreeView1" runat="server" > 
   <Nodes> 
       <telerik:RadTreeNode Text="Node1">  
       <Nodes> 
          <telerik:RadTreeNode Text="Node11"></telerik:RadTreeNode> 
          <telerik:RadTreeNode Text="Node12"></telerik:RadTreeNode> 
       </Nodes> 
       </telerik:RadTreeNode> 
   </Nodes> 
</telerik:RadTreeView> 
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadTreeView1" 
        ErrorMessage="Please select a Node before updating"></asp:RequiredFieldValidator> 
        <br /> 
<asp:Button ID="Button1" CommandName="Update"  Text="Update" runat="server"/>  
</FormTemplate> 
</EditFormSettings> 

Could you paste the ASPX which you tried, if it is different from mine?

Thanks,
Princy.
0
John Giblin
Top achievements
Rank 1
answered on 07 Apr 2009, 07:14 PM
this is what I have inside a Rad Grid:
 <FormTemplate>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Please correct the following problem(s):" />
        <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
            style="border-collapse: collapse;background:white;">
            <tr class="EditFormHeader">
                <td colspan="2" style="font-size: small"><b>User Calls</b></td>
            </tr>
            <tr>
                <td colspan="2"><b>General Info:</b></td>
            </tr>
            <tr>
                <td>
                    <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
                        <tr>
                            <td>Status:</td>
                            <td>
                                <asp:DropDownList ID="ddStatus" runat="server"  SelectedValue='<%# Bind("Status") %>'
                                    AppendDataBoundItems="True">
                                    <asp:ListItem  Text="" Value=""></asp:ListItem>
                                    <asp:ListItem Selected=True Text="Open" Value="Open"></asp:ListItem>
                                    <asp:ListItem  Text="Closed" Value="Closed"></asp:ListItem>
                                    <asp:ListItem  Text="Hold" Value="Hold"></asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Status is required" ControlToValidate="ddStatus" Text="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>Date Opened:</td>
                            <td><telerik:RadDatePicker ID="rdpDateOpened" runat="server" ><DateInput onclick="ToggleOpened()"/></telerik:RadDatePicker></td>
                        </tr>                            
                        <tr>
                            <td>Date Closed:</td>
                            <td><telerik:RadDatePicker ID="rpdDateClosed" runat="server" ><DateInput onclick="Toggleclosed()"/></telerik:RadDatePicker></td>
                        </tr>                            
                        <tr>
                            <td>Ticket Number:</td>
                            <td><asp:TextBox ID="TicketNumber" runat="server" Text='<%# Bind( "TicketNumber") %>' ></asp:TextBox></td>
                        </tr>

                        <tr valign=top>
                            <td>Application:</td>
                            <td valign=top>
                                <div Style="BORDER-RIGHT: gray thin solid; BORDER-TOP: gray thin solid; BORDER-LEFT: gray thin solid; BORDER-BOTTOM: gray thin solid">
                                <Telerik:RadTreeView
                                    Skin="Office2007"
                                    DataSource="<%#GetApplications() %>"
                                    DataFieldID="Id"
                                    CausesValidation=true
                                    DataValueField = "Id"
                                    DataFieldParentID = "ParentId"
                                    DataTextField = "Name"
                                    Id="ApplicationType2"
                                    ImagesBaseDir="~/TreeView/Img/Outlook/"
                                    MultipleSelect="False"
                                    Runat="server"
                                    Width="250px"
                                    Height="300px"
                                    LoadingMessagePosition="BeforeNodeText" >
                                </Telerik:RadTreeView>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="field" ControlToValidate="ApplicationType2" Text="*"></asp:RequiredFieldValidator>
                                  <%--  <asp:RequiredFieldValidator ControlToValidate="ApplicationType2"  ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>--%>
                                </div>
                              
                        </tr>
                    </table>
                </td>
                <td valign=top>
                    <table id="Table1" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
                        <tr>
                            <td>Assigned:</td>
                            <td>
                                <asp:DropDownList ID="ddAssigned" runat="server"  SelectedValue='<%# Bind("Assigned") %>'
                                    AppendDataBoundItems="True">
                                    <asp:ListItem></asp:ListItem>
                                    <asp:ListItem  Text="Anthony Sebastian" Value="asebastian"></asp:ListItem>
                                    <asp:ListItem  Text="Elaine Chin" Value="echin"></asp:ListItem>
                                    <asp:ListItem  Text="John Giblin" Value="jgiblin"></asp:ListItem>
                                    <asp:ListItem  Text="Kelli Watson" Value="kwatson"></asp:ListItem>
                                    <asp:ListItem  Text="Madeline Scaringi" Value="mscaringi"></asp:ListItem>
                                    <asp:ListItem  Text="Madelyn Sindha" Value="MSindha"></asp:ListItem>
                                    <asp:ListItem  Text="Peter Carissimo" Value="pcarissimo"></asp:ListItem>
                                    <asp:ListItem  Text="Tobie Gabriele" Value="tgabriele"></asp:ListItem>
                                    <asp:ListItem  Text="Tom Towey" Value="ttowey"></asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="ddAssigned" runat="server" ErrorMessage="Assigned is required"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td>Referred By:</td>
                            <td><asp:TextBox ID="txtReferredBy" runat="server" Text='<%# Bind( "ReferredBy") %>' ></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td>User:</td>
                            <td><asp:TextBox ID="txtUser" runat="server" Text='<%# Bind( "Username") %>' TabIndex="2"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="txtUser" runat="server" ErrorMessage="User is required" Text="*"></asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td colspan=2>Problem: <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtProblem" ErrorMessage="Problem is required" Text="*"></asp:RequiredFieldValidator></td>
                        </tr>
                        <tr>
                            <td colspan=2><asp:TextBox ID="txtProblem" Text='<%# Bind( "Problem") %>' runat="server" TextMode="MultiLine" Rows="5" Columns="40" TabIndex="5"></asp:TextBox></td>
                        </tr>
                        <tr>
                            <td colspan=2>Resolution:</td>
                        </tr>
                        <tr>
                            <td colspan=2><asp:TextBox ID="txtResultion" Text='<%# Bind( "Resolution") %>' runat="server" TextMode="MultiLine" Rows="5" Columns="40" TabIndex="6"></asp:TextBox></td>
                        </tr>
                        <tr valign=top>
                            <td>Issue:</td>
                            <td><asp:CheckBoxList
                                    ID="cblIssue" DataSource='<%#GetIssues() %>' DataTextField="Name" DataValueField="Id"
                                    runat="server"/></td>
                        </tr>
                        
                    </table>
                </td>
            </tr>
            <tr>
                <td><telerik:radupload id="RadUpload1" runat="server" Skin="Web20" initialfileinputscount="1"
                                  maxfilesize="1000000"
                               />
                        </edititemtemplate></td>
            </tr>
            <tr>
                <td align="right" colspan="2">
                    <asp:Button ID="btnUpdate" Text='<%# (Container is Telerik.WebControls.GridEditFormInsertItem) ? "Insert" : "Update" %>' runat="server" CommandName='<%# (Container is Telerik.WebControls.GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                    </asp:Button>&nbsp;<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
                </td>
            </tr>
        </table>
    </FormTemplate>
0
Sebastian
Telerik team
answered on 08 Apr 2009, 07:01 AM

Hello John,

Can you please check whether the same validation mechanism for the treeview instance works when the control is outside of the RadGrid's FormTemplate custom edit form? You can also check whether setting the MultipleSelect property of the treeview to true makes a difference.

If the issue surfaces only when the control is inside the edit form of the grid, please isolate a stripped working version of your project and send it enclosed to a regular support ticket. We will examine your complete code logic in detail and will get back to you with our findings.
 
Best regards,

Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
John Giblin
Top achievements
Rank 1
answered on 08 Apr 2009, 02:57 PM
Actually I got the same error when I was outside the Rad Grid. I thought you were able to validate a RadTree
0
Veselin Vasilev
Telerik team
answered on 10 Apr 2009, 03:10 PM
Hello John Giblin,

The validation of the treeview should work as expected. You can check our online demo and help article.

The integrated validation is added in Q3 2008 so please check if your version is not older.

Greetings,
Veselin Vasilev
the Telerik team

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