CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2011
    Posts
    1

    session variable help?

    I am tryting to create a session variable where I can store a previous page information if I move on to the next page.



    For example, I selected bunch of ddls on Customer page, then moved on to Employer page.

    w/o session varibles, the information on customer page would be gone.



    I am trying to make it where the things i have selected will still appear when i come back to customer page.

    Do you guys have any idea how to do this?

  2. #2
    Join Date
    Jul 2005
    Location
    Louisville, KY
    Posts
    201

    Re: session variable help?

    If it's a multiselect listbox, I'd simply create a session variable, that had your selections, as a comma delimited string on the changed events, and doing a string split in your current page, and updating everything on the form-load of the new page.

  3. #3
    Join Date
    Dec 2008
    Posts
    144

    Re: session variable help?

    I'm assuming that this is for an ASP .NET application.

    You can put objects straight into Session- you just have to cast them when you pull them out of Session.

    The following example is for dealing with a List<string>

    Code:
    private List<string> m_StringList;
    
    protected void Page_Load(object sender, EventArgs e)
    {
    if (Session["StringList"] != null)
                    m_StringList= (List<string>)Session["StringList"];
    }
    
    private void AddStringToList(string item)
    {
    m_StringList.Add(item);
    Session["StringList"] = m_StringList;
    }
    HTH
    Code:
    if (Issue.Resolved)
    {
         ThreadTools.Click();
         MarkThreadResolved();
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured