UpdatePanel/Accordion/GridView

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stoogots2
    New Member
    • Sep 2007
    • 77

    UpdatePanel/Accordion/GridView

    I'm wondering why I can't find the updatepanel control in my codebehind file Page_Load event. I have several gridviews, each in their own accordion control/pane, all inside an updatepanel (which I was planning to split into one for each accordion when I finally get one UpdatePanel working). I guess it is probably something of which I am ignorant.

    Code:
    upFull = (UpdatePanel) this.Page.FindControl("upFull");
    // the previous line returns null so please be gentle with the beatdown :)
    gvMyWG = (GridView)upFull.ContentTemplateContainer.FindControl("gvMyWG");
    
    gvMyGG = (GridView)upFull.ContentTemplateContainer.FindControl("gvMyGG");
    //Next thing I do is call a static method and pass all grids by reference to set all gridview datasources to a SqlDataReader that is getting multiple result sets (MARS).
    Last edited by Frinavale; Feb 24 '09, 08:39 PM. Reason: Moved to ASP.NET Answers from .NET
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Are your update panels in the MasterPage?

    Or are your update panels in a regular ASP page or Web User Control?
    If so, you shouldn't have to use the FindControl to locate your GridViews.

    Comment

    • stoogots2
      New Member
      • Sep 2007
      • 77

      #3
      Frinavale,

      Thanks for your response. I am sorry I wasted your time. Evidently I did write this properly the first time around, but I kept getting a compiler error when passing GridViews via reference. "Object not set to an instance" so I figured I was doing something wrong (because they were within the UpdatePanel). That's when I started with the "please god let this work because I am falling behind" code :). This isn't the first time that I have written the code properly but the IDE chokes when and gives me build errors. It seems like it is caching it somewhere and refuses to update it when I do a clean solution/rebuild.

      Once again thanks for your help.

      Comment

      • stoogots2
        New Member
        • Sep 2007
        • 77

        #4
        Evidently, I stepped on my "jump to conclusions mat" and celebrated too soon. After I deleted my class variables which were part of the "please god" code, I am now getting the original error message again. "The name gvMyGridView does not exist in this context".
        Here is the control hierarchy:

        MasterPage
        ContentPage
        ContentPlaceHol der
        UpdatePanel
        Accordion
        GridView

        In the page_load event I am just trying to pass each gridview by reference to a static method so they can be bound to a Sqldatareader. I guess I will try ripping out the UpdatePanel for now.

        Comment

        Working...