Keeping an object from being recreated and added to Session on page load/postback

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy B

    Keeping an object from being recreated and added to Session on page load/postback

    I have the following code inside a page_load event:

    DataSet Store = new DataSet();
    Session["Store"]=Store;

    Every time the page loads, refreshes or the wizard flips from 1 wizardstep
    to another, the dataSet is wiped out and reasigned to the Session making it
    impossible to get anywhere. How do you stop stuff like this?




  • Mark Rae [MVP]

    #2
    Re: Keeping an object from being recreated and added to Session on page load/postback

    "Andy B" <a_borka@sbcglo bal.netwrote in message
    news:ORHlEcHvIH A.5580@TK2MSFTN GP04.phx.gbl...
    How do you stop stuff like this?
    if (!IsPostBack)
    {
    DataSet Store = new DataSet();
    Session["Store"]=Store;
    }


    --
    Mark Rae
    ASP.NET MVP


    Comment

    • gerry

      #3
      Re: Keeping an object from being recreated and added to Session on page load/postback


      if ( Session["Store"] == null )
      {
      DataSet Store = new DataSet();
      Session["Store"]=Store;
      }



      "Andy B" <a_borka@sbcglo bal.netwrote in message
      news:ORHlEcHvIH A.5580@TK2MSFTN GP04.phx.gbl...
      >I have the following code inside a page_load event:
      >
      DataSet Store = new DataSet();
      Session["Store"]=Store;
      >
      Every time the page loads, refreshes or the wizard flips from 1 wizardstep
      to another, the dataSet is wiped out and reasigned to the Session making
      it impossible to get anywhere. How do you stop stuff like this?
      >
      >
      >
      >

      Comment

      Working...