A frustrating problem. Help greatly appreciated! :-(

Discussion in 'ASP .Net' started by Simon Harvey, Apr 2, 2004.

  1. Simon Harvey

    Simon Harvey Guest

    Hi,

    I'm hoping someone can help me witht he following problem:

    I have a fairly simple page that has a sort form and a button for adding the
    forms details to an arraylist.

    When the button is pressed, the information from the form needs to be added
    to a list in the bottom half of the page.

    The problem I am having is to do with persisting the array and displaying
    the list.

    When the button is pressed I am adding the information to the array and
    adding the array to the Session.

    In page load, I am reading from the session and displaying the info in the
    array.

    The problem is, the pageload event happens BEFORE the button click event, so
    the new data isn't added to the array until after page load has run. Which
    is rubbish!

    Does anyone know how I can fix this or do it in a different way to get the
    right result?

    Thanks to anyone who can help

    Kindest Regards

    Simon
     
    Simon Harvey, Apr 2, 2004
    #1
    1. Advertisements

  2. Simon Harvey

    Guest Guest

    What you probably want to do is something like this

    function DisplayListAtBottomofPage()
    {
    ... code to display list a tbottom of page goes here from the session
    variable
    }

    Page_Load (...)
    {
    if (IsPostBack==false) { DisplayListATBottomOfPage(); } // this only
    fires if we are not postingback aka a button was not pressed
    }
    Button1_ServerClick(..._)
    {
    // Add Item to array
    // Save Array in the Session
    DisplayListAtBottomOfPage();

    }




    Hope this helps. Posting is provided as is
     
    Guest, Apr 2, 2004
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.