Forums

GridView data lost during drill-down

Last post 1/6/2009 3:47 PM by Joel Mundt. 1 replies.
Sort Posts: Previous Next
  • Joel Mundt

    GridView data lost during drill-down

    1/5/2009 11:00 AM
    • Top 500 Contributor
    • Joined on 10/29/2008
    • Iowa
    • Posts 35

    I apologize in advance for the length of this...

    The Setup:

    I've run into a goofy problem with my ASPxGridView project...and I think there's a simple solution, but I can't see it.  I've got a 3-tier GridView as follows:

    The main GridView (ciGrid) has as its DetailRow a PageControl (ciPages) with 4 tabs, the 4th of which is another GridView (doGrid).  doGrid also has as its DetailRow a PageControl (doPages) with 4 tabs, the 4th of which is, again, another GridView (tGrid).  tGrid has as its DetailRow yet another PageControl (tPages) with only 3 tabs...here the drill-down ends.

    The Problem:

    When the control runs, the first GridView displays 5 records, and expanding each record works fine.  But if I try to drill down into that second level (the doGrid), no information is returned.  It's as though the Grids have lost track of the current row being shown and all the other rows I've opened.  Now if I open just the first of those 5 records and drill down from there, data is displayed correctly.  I'm almost 100% sure it's my code because the "Detail Tabs" demo in the "Master-Detail" section of the ASPxGridView demo is nearly identical to what I'm doing (mine's just more involved).

    I've included the BeforePerformDataSelect events I use below, as well as the more important HtmlRowCreated events, where I think my error is occuring.  I set a CurrentRow session variable for each GridView as the user clicks down through the GridViews so I can keep track of where I am, but I think that's somehow messing up the Grids in light of how the events are firing.  I've bolded the rows where I set the session variables, and where I subsequently use them...I think this is where my error is happening.

    Have I given you enough code to kind of diagnose what I'm doing wrong?  I can attach the code for the entire control, but with all the DB calls and such, you won't get much action from it.  Plus there are a dozen ASPxGauge controls involved and the C# code gets kind of long.

    The Code:

    protected void ciGrid_HtmlRowCreated( object sender, ASPxGridViewTableRowEventArgs e ) {
       if( e.RowType != GridViewRowType.Detail )
          return;

       // Set a session variable to hold the row of the current CI.  This will
       // be used later when clicking on subsequent Desired Outcomes & Tactics.
       Session["ciCurrentRow"] = e.VisibleIndex;

       // Pull the Critical Issue ID from the active GridView row.
       string ciKey = ciGrid.GetRowValues( e.VisibleIndex, "issue_id" ).ToString();

       // Locate the ASPxPageControl, then apply the data.
       ASPxPageControl ciPage = (ASPxPageControl)ciGrid.FindDetailRowTemplateControl( e.VisibleIndex, "ciPages" );

       if( ciPage != null ) {
          // Find the various controls on the other tabs and do some stuff...
       }
    }


    protected void doGrid_BeforePerformDataSelect( object sender, EventArgs e ) {
       Session["IssueID"] = ( sender as ASPxGridView ).GetMasterRowKeyValue();
    }


    protected void doGrid_HtmlRowCreated( object sender, ASPxGridViewTableRowEventArgs e ) {
       if( e.RowType != GridViewRowType.Detail )
          return;

       // Set a session variable to hold the current Desired Outcome row.
       Session["doCurrentRow"] = e.VisibleIndex;

       // Start at the CI control and find the page control for the current CI.
       ASPxPageControl ciPage = (ASPxPageControl)ciGrid.FindDetailRowTemplateControl( int.Parse( Session["ciCurrentRow"].ToString() ), "ciPages" );

       // If the page returned wasn't null then continue.
       if( ciPage != null ) {

          // Now locate the DO grid within the CI page control.
          ASPxGridView tdoGrid = (ASPxGridView)ciPage.FindControl( "doGrid" );

          // Make sure the DO values are returned.
          if( tdoGrid.GetRowValues( e.VisibleIndex, "outcome_id" ) != null ) {

             // Pull the Desired Outcome ID from the active GridView row.
             string doKey = tdoGrid.GetRowValues( e.VisibleIndex, "outcome_id" ).ToString();

             // Locate the ASPxPageControl, then apply the data.
             ASPxPageControl doPage = (ASPxPageControl)tdoGrid.FindDetailRowTemplateControl( e.VisibleIndex, "doPages" );

             if( doPage != null ) {
                // Find the various controls on the other tabs and do some stuff...
             }
          }
       }
    }


    protected void tGrid_BeforePerformDataSelect( object sender, EventArgs e ) {
       Session["OutcomeID"] = ( sender as ASPxGridView ).GetMasterRowKeyValue();
    }


    protected void tGrid_HtmlRowCreated( object sender, ASPxGridViewTableRowEventArgs e ) {
       if( e.RowType != GridViewRowType.Detail )
          return;

       // Set a session variable to hold the current Tactic row.
       Session["tCurrentRow"] = e.VisibleIndex;

       // Start at the CI control and find the page control for the current CI.
       ASPxPageControl ciPage = (ASPxPageControl)ciGrid.FindDetailRowTemplateControl( int.Parse( Session["ciCurrentRow"].ToString() ), "ciPages" );

       // If the page returned wasn't null then continue.
       if( ciPage != null ) {

          // Now locate the DO grid within the CI page control.
          ASPxGridView tdoGrid = (ASPxGridView)ciPage.FindControl( "doGrid" );

          // Find the Tactic page control within the DO grid.
          ASPxPageControl doPage = (ASPxPageControl)tdoGrid.FindDetailRowTemplateControl( int.Parse( Session["doCurrentRow"].ToString() ), "doPages" );

          if( doPage != null ) {

             ASPxGridView ttGrid = (ASPxGridView)doPage.FindControl( "tGrid" );

             if( ttGrid != null ) {

                // Pull the Tactic ID from the active GridView row.
                string tKey = ttGrid.GetRowValues( e.VisibleIndex, "tactic_id" ).ToString();

                // Locate the ASPxPageControl, then apply the data.
                ASPxPageControl tPage = (ASPxPageControl)ttGrid.FindDetailRowTemplateControl( e.VisibleIndex, "tPages" );

                if( tPage != null ) {
                   // Find the various controls on the other tabs and do some stuff...
                }
             }
          }
       }
    }

    Any help is most appreciated...I'm pulling my hair out over this one.  If you need more info, let me know.

    Regards,
    Joel

    Filed under:
  • Joel Mundt

    Re: GridView data lost during drill-down

    1/6/2009 3:47 PM
    • Top 500 Contributor
    • Joined on 10/29/2008
    • Iowa
    • Posts 35

    Somebody in this forum (or at DevExpress) needs to hit me with a 10-pound hammer.  I figured out my problem...painfully obvious, like most things when you finally see the solution.

    I was spending all that time drilling down through the various GridViews (which was definitely messing things up), when all along, the sender was the exact GridView I needed.

    To anyone who read my initial post, I apologize for wasting 10 minutes of your life. Smile

    Regards,
    Joel

     

    Filed under:
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.