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

FindControl in Grid/MasterTableview/DetailTables/...

3 Answers 528 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 08 Mar 2011, 02:51 PM

Having a bit of trouble just finding a control in this.
I have cleared out most code for an easier read and left the main tags in place.
Need to find the SqlDataSource and I have tried everything with no luck....

 

 

    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="odsFill" GridLines="None"
    AllowPaging="True" Width="950px" DataKeyNames="xxx">
    <MasterTableView DataSourceID="odsFill" AutoGenerateColumns="False" DataKeyNames="xxx"
        AllowPaging="true">
        <RowIndicatorColumn HeaderStyle-Width="20px" />
        <ExpandCollapseColumn HeaderStyle-Width="20px" />
        <Columns>
              
        </Columns>
        <DetailTables>
            <telerik:GridTableView runat="server" >
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="xxx" MasterKeyField="xxx" />
                </ParentTableRelation>
                <NoRecordsTemplate>
                    There are no records.</NoRecordsTemplate>
                <Columns>                            
                    <telerik:GridTemplateColumn DataField="TYPE" UniqueName="xxx" HeaderText="C">
                        <ItemTemplate>
                            <asp:HyperLink ID="create3Clink" runat="server" Text="Create 3C" 
                                NavigateUrl='default.aspx' />                                    
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
                <NestedViewSettings>
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="COMP_ID" MasterKeyField="COMP_ID" />
                    </ParentTableRelation>
                </NestedViewSettings>
                <NestedViewTemplate>
                    <asp:Label ID="lblID" Text='test' runat="server" />
                    <telerik:RadTabStrip runat="server" ID="TabStip1" MultiPageID="Multipage1" SelectedIndex="0">
                        <Tabs>
                            <telerik:RadTab runat="server" Text="Verification" PageViewID="PageView3" />                                    
                        </Tabs>
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage runat="server" ID="Multipage1" SelectedIndex="0" RenderSelectedPageOnly="false">
                        <telerik:RadPageView runat="server" ID="PageView3" BorderStyle="Solid">
                            <h4>
                                Verification</h4>
                                  
                                  
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ToolBox %>"
                                SelectCommand="SELECT * From MyTable">                                        
                            </asp:SqlDataSource>
                              
                             
                        </telerik:RadPageView>
                      
                    </telerik:RadMultiPage>
                </NestedViewTemplate>
            </telerik:GridTableView>
        </DetailTables>
    </MasterTableView>
</telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Mar 2011, 06:46 AM
Hello Tim,

The following code snippet shows how to access the control  from an an external button click event.

C#:
protected void Button1_Click(object sender, EventArgs e)
    {
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {
                GridTableView tableView = (GridTableView)item.ChildItem.NestedTableViews[0];
                foreach (GridNestedViewItem childitem in tableView.GetItems(GridItemType.NestedView))
                {
                     RadPageView pageView = (RadPageView)childitem.FindControl("PageView3");
                    SqlDataSource source = (SqlDataSource)pageView.FindControl("SqlDataSource1");
                }
        }
    }


Thanks,
Princy.
0
Tim
Top achievements
Rank 1
answered on 09 Mar 2011, 03:56 PM
Thanks for the info. I am able to access it now but ran into another problem.
I am trying to set the connection string for the sqldatasource.
I am encrypting it in the web.config. (I inherited this app)

Now, if I set it in the page Init, no data comes back like it should.
If I set it in the page load and on each post back, the error comes up that the conn string has not been initialized.

Suggestions on this?

Thanks in advance...
0
Vasil
Telerik team
answered on 14 Mar 2011, 03:13 PM
Hi Tim,

Try to decrypt the connection string on Page_PreInit event.

Best wishes,
Vasil
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Tim
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or