Datagrid with unbound column(checkbox)

Discussion in 'ASP .Net Web Controls' started by Mike, Dec 19, 2003.

  1. Mike

    Mike Guest

    Hello all,

    I think I have a scope problem here, and I don't know how
    to fix it.

    I have a module that contains the declaration for an
    arraylist. Then I have a form that uses the arraylist,
    populates and deletes items in it. The arraylist is fine
    unless there are multiple people in the form doing
    transactions that affect the arraylist. User 1 adds 5
    records to the arraylist as well does user 2. When the
    page does a postback, user 1 and 2 both see 10 records in
    the arraylist. I have tried to define the arraylist in
    the form but everytime the page does a postback, the
    array is recreated and I lose my data. Any ideas on how
    to fix this problem.

    Thanks,
    Mike
     
    Mike, Dec 19, 2003
    #1
    1. Advertising

  2. Mike

    Sink Guest

    Hi Mike,
    Sounds like you have a static defined
    ArrayList in your module.
    You could set up seperate lists for each User of the
    form.
    If you are using Sessions to track such data and
    reside in a class type module, then you will need to
    access the HttpContext to get access to the individual
    Session data.

    ....
    Using System. Collections;
    Using System.Web;
    ....

    public ArrayList my_list;

    HttpContext ctx = HttpContext.Current;

    my_list = (ArrayList)ctx.Session["my_list"];
    if(my_list == null){
    my_list = new ArrayList();

    }

    // To Save your list

    ctx.Session["my_list"] = my_list;

    Alternatively, of course, you could just expand
    your ArrayList to contain some class of objects that
    include the UserID or some sort of Identifier and
    then search the list for only those.

    Finally, if you move into your code behind module,
    you can use Session without the HttpContext addressing.

    Regards
    G.,



    >-----Original Message-----
    >Hello all,
    >
    >I think I have a scope problem here, and I don't know how
    >to fix it.
    >
    >I have a module that contains the declaration for an
    >arraylist. Then I have a form that uses the arraylist,
    >populates and deletes items in it. The arraylist is fine
    >unless there are multiple people in the form doing
    >transactions that affect the arraylist. User 1 adds 5
    >records to the arraylist as well does user 2. When the
    >page does a postback, user 1 and 2 both see 10 records in
    >the arraylist. I have tried to define the arraylist in
    >the form but everytime the page does a postback, the
    >array is recreated and I lose my data. Any ideas on how
    >to fix this problem.
    >
    >Thanks,
    >Mike
    >.
    >
     
    Sink, Dec 22, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keithb
    Replies:
    1
    Views:
    2,786
    Teemu Keiski
    Apr 8, 2006
  2. John

    Adding unbound checkbox to grid

    John, Apr 14, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    626
  3. David C

    GridView unbound checkbox state

    David C, Mar 5, 2009, in forum: ASP .Net
    Replies:
    2
    Views:
    2,362
    David C
    Mar 5, 2009
  4. Gregory Rampton

    Convert an MS Access Yes/No column to a checkbox column in C# datagrid

    Gregory Rampton, Aug 6, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    244
    Gregory Rampton
    Aug 6, 2003
  5. Gary Frank

    Bound datatable + unbound column in datagrid

    Gary Frank, Aug 25, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    236
    Elton Wang
    Aug 25, 2005
Loading...

Share This Page