XmlDataSource FindControl within FormView and TabContainer

Posted on 2011-10-20
Last Modified: 2012-05-12
I have a Gridview displaying data from a xml datasource that I am populating in codebehind which displays the data if placed in a plain web page but I need to add the data within a FormView and TabContainer. When I add the gridview inside the Formview nothing is displayed.

I have other Datalist and Gridviews within the formview and inside tabcontainers which all display ok using the following findcontrol

            DataList CostOnSiteDataList = (DataList)PropertyForm.FindControl("propertycontainer").FindControl("Panel2").FindControl("COSDataList");

This is the Gridview;

                                                         <asp:GridView ID="COSGridView" DataSourceID="XmlDataSourceCOS" GridLines="None" runat="server" Width="100%" AutoGenerateColumns="false" BackColor="#FFFFFF" ShowHeader="False">
                                                                        <table width="100%">
                                                                        <tr valign="top">
                                                                        <td align="left">
                                                                        <asp:Label ID="Costs_Description_Label" runat="server" CssClass="pdheading" Text='<%# XPath("Description") %>' /><br />
                                                                        <td align="right">
                                                                        <asp:Label ID="Costs_Value_Label" runat="server" CssClass="pdheading" Text='<%# XPath("Value") %>' />
    <asp:XmlDataSource ID="XmlDataSourceCOS" EnableCaching="false" runat="server" XPath="//COS" />

and the code behind data tag which loadsa the data when the gridview is outside of the formview.

             XmlDataSourceCOS.Data = root9.OuterXml;


                                <asp:FormView ID="PropertyForm" runat="server" Width="100%" CellSpacing="3">
    <cc1:tabcontainer runat="server" id="propertycontainer" width="955px" cssclass="mytabs" onclientactivetabchanged="ActiveTabChanged">
        <cc1:TabPanel runat="Server" ID="Panel1" HeaderText="Information">
Question by:chrispaton
    LVL 96

    Expert Comment

    by:Bob Learned
    If you move a control inside of another naming container, then it would change the behavior for FindControl, which might be the reason for your problems...

    Accepted Solution

    In the end I had to remove the formview and change the page design as this was the only way I could get this to work properly

    Author Closing Comment

    The suggestion made did not work as the item was still not displaying data on the page

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now