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

How to find nested controls - setting properties for nested controls

1 Answer 141 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rodney
Top achievements
Rank 1
Rodney asked on 03 Apr 2013, 02:46 PM
I can't find any documentation or examples of how to acheive the following.

I have a RadGrid using a panel/multipage with a RadWindow on one of the multipages, all inside a edit template. (See code below)

I would like to set the NavigateURL based on the values of two text box controls (on the same multipage).  These are the latitude and longitude of a location to be displayed in Bing maps.

http://dev.virtualearth.net/embeddedMap/v1/ajax/aerial?zoomLevel=10&center=41.095694_-85.109793&pushpins=41.095694_-85.109793


In the codebehind I can access and set only the RadGrid1 properties.

What is the method for finding the nested controls? Please provide your code example responses in VB.

Thanks in advance!

<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function RowDblClick(sender, eventArgs) {
            sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
        }
    </script>
</telerik:RadCodeBlock>
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" CellSpacing="0" DataSourceID="SqlDataSource1" GridLines="None" Skin="Office2010Blue" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
        <Selecting AllowRowSelect="True" />
        <ClientEvents OnRowDblClick="RowDblClick" />
    </ClientSettings>
    <MasterTableView DataKeyNames="LocationID" DataSourceID="SqlDataSource1" CommandItemDisplay="Top">
        <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:GridEditCommandColumn ButtonType="ImageButton" FilterControlAltText="Filter EditCommandColumn column">
            </telerik:GridEditCommandColumn>
            <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ConfirmText="Are you sure you want to delete this record? This action cannot be undone." FilterControlAltText="Filter column column" UniqueName="column">
            </telerik:GridButtonColumn>
            <telerik:GridBoundColumn DataField="LocationID" DataType="System.Int32" FilterControlAltText="Filter LocationID column" HeaderText="ID" ReadOnly="True" SortExpression="LocationID" UniqueName="LocationID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LocationName" FilterControlAltText="Filter LocationName column" HeaderText="LocationName" SortExpression="LocationName" UniqueName="LocationName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="InternalName" FilterControlAltText="Filter InternalName column" HeaderText="InternalName" SortExpression="InternalName" UniqueName="InternalName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="LocationType" FilterControlAltText="Filter LocationType column" HeaderText="LocationType" SortExpression="LocationType" UniqueName="LocationType">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="EntityID" FilterControlAltText="Filter EntityID column" HeaderText="EntityID" SortExpression="EntityID" UniqueName="EntityID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Latitude" FilterControlAltText="Filter Latitude column" HeaderText="Latitude" SortExpression="Latitude" UniqueName="Latitude">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Longitude" FilterControlAltText="Filter Longitude column" HeaderText="Longitude" SortExpression="Longitude" UniqueName="Longitude" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Address1" FilterControlAltText="Filter Address1 column" HeaderText="Address1" SortExpression="Address1" UniqueName="Address1">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Address2" FilterControlAltText="Filter Address2 column" HeaderText="Address2" SortExpression="Address2" UniqueName="Address2" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="City" FilterControlAltText="Filter City column" HeaderText="City" SortExpression="City" UniqueName="City">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="State" FilterControlAltText="Filter State column" HeaderText="State" SortExpression="State" UniqueName="State">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ZIP" FilterControlAltText="Filter ZIP column" HeaderText="ZIP" SortExpression="ZIP" UniqueName="ZIP">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="County" FilterControlAltText="Filter County column" HeaderText="County" SortExpression="County" UniqueName="County" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Phone" FilterControlAltText="Filter Phone column" HeaderText="Phone" SortExpression="Phone" UniqueName="Phone" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Services" FilterControlAltText="Filter Services column" HeaderText="Services" SortExpression="Services" UniqueName="Services" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Amenities" FilterControlAltText="Filter Amenities column" HeaderText="Amenities" SortExpression="Amenities" UniqueName="Amenities" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Details" FilterControlAltText="Filter Details column" HeaderText="Details" SortExpression="Details" UniqueName="Details" Visible="False">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="moreInfoURL" FilterControlAltText="Filter moreInfoURL column" HeaderText="moreInfoURL" SortExpression="moreInfoURL" UniqueName="moreInfoURL" Visible="False">
            </telerik:GridBoundColumn>
        </Columns>
 
        <EditFormSettings EditFormType="Template">
            <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
            <FormTemplate>
                <telerik:RadTabStrip ID="RadTabStrip2" runat="server" Skin="Office2007" MultiPageID="RadMultiPage1"
                    SelectedIndex="0" Align="Justify" ReorderTabsOnSelect="True" Width="800px">
 
                    <Tabs>
                        <telerik:RadTab Text="General">
                        </telerik:RadTab>
 
                        <telerik:RadTab Text="Mapping" Selected="True">
                        </telerik:RadTab>
 
                        <telerik:RadTab Text="Photo">
                        </telerik:RadTab>
 
                        <telerik:RadTab Text="Services">
                        </telerik:RadTab>
 
                        <telerik:RadTab Text="Amenities">
                        </telerik:RadTab>
 
                        <telerik:RadTab Text="Details">
                        </telerik:RadTab>
                    </Tabs>
 
                </telerik:RadTabStrip>
                <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" CssClass="pageView" Width="800px">
                    <!--- GENERAL TAB --->
                    <telerik:RadPageView ID="RadPageView1" runat="server">
                    </telerik:RadPageView>
 
                    <!--- MAPPING TAB --->
                    <telerik:RadPageView ID="RadPageView2" runat="server">
                        <table cellpadding="5" style="padding-top: 25px;">
                            <tr valign="top">
                                <td width="400">
                                    <table cellpadding="5">
                                        <tr>
                                            <td class="tdName">Latitude:</td>
                                            <td>
                                                <telerik:RadTextBox ID="txtLatitude" runat="server" LabelWidth="64px" Text='<%# Bind("Latitude") %>' Width="225px"></telerik:RadTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tdName">Longitude:</td>
                                            <td>
                                                <telerik:RadTextBox ID="txtLongitude" runat="server" LabelWidth="64px" Text='<%# Bind("Longitude") %>' Width="225px"></telerik:RadTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:Button ID="btnLatLng" runat="server" Text="View Map" OnClick="btnLatLng_Click" CommandArgument="41.095694_-85.109793" /></td>
                                        </tr>
                                    </table>
                                </td>
                                <td width="400">
                                    <telerik:RadWindowManager Behaviors="Resize, Close, Maximize, Move" ID="RadWindowManager" DestroyOnClose="True"
                                        RestrictionZoneID="RestrictionZone" Opacity="99" runat="server" Width="300px" Height="400px" Visible="true" Skin="Office2007" Behavior="Resize, Close, Maximize, Move">
 
                                        <Windows>
                                            <telerik:RadWindow ID="RadWindow1" VisibleOnPageLoad="true" Title="Location Map" NavigateUrl='http://dev.virtualearth.net/embeddedMap/v1/ajax/aerial?zoomLevel=10¢er=41.095694_-85.109793&pushpins=41.095694_-85.109793'
                                                IconUrl="telerikFavicon.ico" Modal="True" runat="server" VisibleStatusbar="False" VisibleTitlebar="true" Visible="false">
                                            </telerik:RadWindow>
                                        </Windows>
 
                                    </telerik:RadWindowManager>
                                </td>
                            </tr>
                        </table>
 
                    </telerik:RadPageView>
 
                    <!--- PHOTO TAB --->
                    <telerik:RadPageView ID="RadPageView3" runat="server">
                        <table cellpadding="10">
                            <tr valign="top">
                                <td width="400">
                                    <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server">
                                    </telerik:RadAsyncUpload>
                                </td>
                                <td width="400" align="center"></td>
                            </tr>
                        </table>
                    </telerik:RadPageView>
 
                    <!--- SERVICES TAB --->
                    <telerik:RadPageView ID="RadPageView4" runat="server">
                        <telerik:RadEditor Visible="true" ID="RadEditor1" runat="server" Width="100%" Height="350px" Content='<%# Bind("Services") %>' Skin="Office2007" ToolbarMode="Default" ToolsFile="~/tools.xml"></telerik:RadEditor>
                    </telerik:RadPageView>
 
                    <!--- AMENITIES TAB --->
                    <telerik:RadPageView ID="RadPageView5" runat="server">
                        <telerik:RadEditor Visible="true" ID="RadEditor2" runat="server" Width="100%" Height="350px" Content='<%# Bind("Amenities") %>' Skin="Office2007" ToolbarMode="Default" ToolsFile="~/tools.xml"></telerik:RadEditor>
                    </telerik:RadPageView>
 
                    <!--- DETAILS TAB --->
                    <telerik:RadPageView ID="RadPageView6" runat="server">
                        <telerik:RadEditor Visible="true" ID="RadEditor3" runat="server" Width="100%" Height="350px" Content='<%# Bind("Details") %>' Skin="Office2007" ToolbarMode="Default" ToolsFile="~/tools.xml"></telerik:RadEditor>
                    </telerik:RadPageView>
 
                </telerik:RadMultiPage>
            </FormTemplate>
        </EditFormSettings>
 
        <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
    </MasterTableView>
 
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
 
    <FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 08 Apr 2013, 10:56 AM
Hello,

 When the item is in edit mode you can use the server-side FindControl method to access first the RadMultiPageView and then go deeper in the control hierarchy until you reach the textboxes and the RadWindow manager. The GridItemDataBound event is suitable to for this approach. Here is a sample code:

Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    Dim editItem = TryCast(e.Item, GridEditFormItem)
    If editItem IsNot Nothing AndAlso editItem.IsInEditMode Then
        Dim multiPage = TryCast(editItem.FindControl("RadMultiPage1"), RadMultiPage)
        Dim window = TryCast(multiPage.FindControl("RadWindow1"), RadWindow)
        Dim txtLatitude = TryCast(multiPage.FindControl("txtLatitude"), RadTextBox)
        Dim txtLongitude = TryCast(multiPage.FindControl("txtLongitude"), RadTextBox)
 
        window.NavigateUrl = "..."
    End If
End Sub

Additional information can also be found in the following help article:
http://www.telerik.com/help/aspnet-ajax/grid-updating-values-usercontrol-formtemplate.html

Regards,
Marin
the Telerik team
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 their blog feed now.
Tags
General Discussions
Asked by
Rodney
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or