GridView Save OnActiveTabChanged

Last post 11-02-2009 9:22 AM by ddelella. 5 replies.

Sort Posts:

  • GridView Save OnActiveTabChanged

    10-29-2009, 5:02 PM
    • Member
      22 point Member
    • ddelella
    • Member since 08-17-2007, 2:47 PM
    • Cincinnati, OH
    • Posts 69

    I have a page with at least 6 tabs in a TabContainer control using AJAX.  I already enabled post backs when switching tabs so I could use the OnActiveTabChanged method.  In this method I am trying to save the data on the tab I am leaving and call a public load function in the user control for the tab I am loading.  Each tab is a user control with a load and save public commands.  I am running into the typical postback issue of loosing data on the currently loaded tab when the postback occurs.  In particular I have a GridView that has a drop down list and a checkbox.  When I save the tab I need to update my DataTable with the latest selections from the dropdown and the check box.  I can not do this in the standard edit row format, it has to all be editable at the same time.  Any ideas on how to perform this load and save a little nicer.  I would provide code but it is really long and the logic is more important in this case.  Thanks 

  • Re: GridView Save OnActiveTabChanged

    10-30-2009, 12:04 AM
    • Star
      7,692 point Star
    • thuhue
    • Member since 09-18-2003, 1:54 PM
    • Posts 2,262

    "In particular I have a GridView that has a drop down list and a checkbox.  When I save the tab I need to update my DataTable with the latest selections from the dropdown and the check box.  I can not do this in the standard edit row format, it has to all be editable at the same time."

    Please elaborate in slow motion details the above statement, especially "I can not do this in the standard edit row format, it has to all be editable at the same time." I am sorry I don't quite undestand what your problem is.

     

    Please mark the post(s) that have helped you as "Answer"
  • Re: GridView Save OnActiveTabChanged

    10-30-2009, 10:37 AM
    • Member
      22 point Member
    • ddelella
    • Member since 08-17-2007, 2:47 PM
    • Cincinnati, OH
    • Posts 69

    A page contains a AJAX TabContainer.  There are two tabs.  In tab 1 is a GridView control.  The grid has a list of countries, a template column with a checkbox, and another template column with a drop down list.  The user can check and uncheck the boxes and select an option for any country.  There is no EditCommandColumn for the GridView.  When I switch to tab two I want to save any of the options change in the Grid on tab 1.  That is a slim downed one step at a time version. 

  • Re: GridView Save OnActiveTabChanged

    10-30-2009, 10:48 AM
    • Star
      7,692 point Star
    • thuhue
    • Member since 09-18-2003, 1:54 PM
    • Posts 2,262

    What about  using ViewState or Session variables , or a row in a temp table to save the special values selected in tab 1 before clicking on tab 2?

    Please mark the post(s) that have helped you as "Answer"
  • Re: GridView Save OnActiveTabChanged

    11-02-2009, 8:26 AM
    • Member
      22 point Member
    • ddelella
    • Member since 08-17-2007, 2:47 PM
    • Cincinnati, OH
    • Posts 69

    This would work but I can not find a spot to save the values in the old fields.  The only function used to detect the changing tabs is OnActiveTabChanged which does not contain the original values anymore.  This method is only activated after the callback.  Without adding a save button I do not see any method which is called before the postback or a way to access the old data before the postback to save it. 

  • Re: GridView Save OnActiveTabChanged

    11-02-2009, 9:22 AM
    Answer
    • Member
      22 point Member
    • ddelella
    • Member since 08-17-2007, 2:47 PM
    • Cincinnati, OH
    • Posts 69

     I stumbled on a workable but not optimal solution.  I added Autopostbacks to the GridView and wrapped it in an UpdatePanel.  These fire Async post backs which update the DataTable which is populating the GridView.  The DataTable is stored in the session and therefore the information for the GridView is maintained on tab changing.  There is minimal latency needed to do the DataTable change so this solution should work.

Page 1 of 1 (6 items)