Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. problem with GridView derived control selected items state maintainance set/reset

problem with GridView derived control selected items state maintainance set/reset

Scheduled Pinned Locked Moved ASP.NET
questioncsharpasp-netdatabasedesign
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VenkataRamana Gali
    wrote on last edited by
    #1

    hi, in my project we are using asp.net 2.0 GridView in so many places. Through out the project we are using GridView derived control.

    public class GridView : System.Web.UI.WebControls.GridView
    {
    //logic
    }

    i have added code to maintain seleced checkboxes state, DataKey value ID of selected rows if user selects multiple rows from multiple pages navigation. i am storing the 1) ID, 2) Selected in the ViewState in the form of List. For this i have 2 methods

    StoreCurrentViewState() //Here i am adding, removing the entries into the ViewState list
    RestorePastViewState //Here i am resetting the checkedboxes.

    this code i have used at...

    protected override void OnPageIndexChanging(GridViewPageEventArgs e)
    {
          StoreCurrentViewState();
          base.OnPageIndexChanging(e);
          RestorePastViewState();
    }

    also added at

    protected override void OnDataBinding(EventArgs e)
    {
          StoreCurrentViewState();
          base.OnDataBinding(e);
    }

    protected override void OnDataBound(EventArgs e)
    {
          base.OnDataBound(e);
          RestorePastViewState();
    }

    it is maintaining selected checkboxes states during the gridview page naigation. my query is ... in one aspx page i have 4 grids and for all page it is storing in single ViewState object. i wanted to store these values in sepearate viewstate for each gridview && i need to reset the ViewState object if gridview loads first time. How can i do? please provide ur inputs...

    Ramana

    R Z 2 Replies Last reply
    0
    • V VenkataRamana Gali

      hi, in my project we are using asp.net 2.0 GridView in so many places. Through out the project we are using GridView derived control.

      public class GridView : System.Web.UI.WebControls.GridView
      {
      //logic
      }

      i have added code to maintain seleced checkboxes state, DataKey value ID of selected rows if user selects multiple rows from multiple pages navigation. i am storing the 1) ID, 2) Selected in the ViewState in the form of List. For this i have 2 methods

      StoreCurrentViewState() //Here i am adding, removing the entries into the ViewState list
      RestorePastViewState //Here i am resetting the checkedboxes.

      this code i have used at...

      protected override void OnPageIndexChanging(GridViewPageEventArgs e)
      {
            StoreCurrentViewState();
            base.OnPageIndexChanging(e);
            RestorePastViewState();
      }

      also added at

      protected override void OnDataBinding(EventArgs e)
      {
            StoreCurrentViewState();
            base.OnDataBinding(e);
      }

      protected override void OnDataBound(EventArgs e)
      {
            base.OnDataBound(e);
            RestorePastViewState();
      }

      it is maintaining selected checkboxes states during the gridview page naigation. my query is ... in one aspx page i have 4 grids and for all page it is storing in single ViewState object. i wanted to store these values in sepearate viewstate for each gridview && i need to reset the ViewState object if gridview loads first time. How can i do? please provide ur inputs...

      Ramana

      R Offline
      R Offline
      r a m e s h
      wrote on last edited by
      #2

      Use ID or UniqueID of GridViews as the key when storing to ViewState. As each ID is going to be unique in a page, they will be maintained separately for each GriView in ViewState object.

      1 Reply Last reply
      0
      • V VenkataRamana Gali

        hi, in my project we are using asp.net 2.0 GridView in so many places. Through out the project we are using GridView derived control.

        public class GridView : System.Web.UI.WebControls.GridView
        {
        //logic
        }

        i have added code to maintain seleced checkboxes state, DataKey value ID of selected rows if user selects multiple rows from multiple pages navigation. i am storing the 1) ID, 2) Selected in the ViewState in the form of List. For this i have 2 methods

        StoreCurrentViewState() //Here i am adding, removing the entries into the ViewState list
        RestorePastViewState //Here i am resetting the checkedboxes.

        this code i have used at...

        protected override void OnPageIndexChanging(GridViewPageEventArgs e)
        {
              StoreCurrentViewState();
              base.OnPageIndexChanging(e);
              RestorePastViewState();
        }

        also added at

        protected override void OnDataBinding(EventArgs e)
        {
              StoreCurrentViewState();
              base.OnDataBinding(e);
        }

        protected override void OnDataBound(EventArgs e)
        {
              base.OnDataBound(e);
              RestorePastViewState();
        }

        it is maintaining selected checkboxes states during the gridview page naigation. my query is ... in one aspx page i have 4 grids and for all page it is storing in single ViewState object. i wanted to store these values in sepearate viewstate for each gridview && i need to reset the ViewState object if gridview loads first time. How can i do? please provide ur inputs...

        Ramana

        Z Offline
        Z Offline
        Zafar A khan
        wrote on last edited by
        #3

        store the viewstate as GridviewID$ID and then split it on restoring.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups