Solved

How to pass arraylist between updatepanels

Posted on 2010-11-25
11
366 Views
Last Modified: 2012-05-10
Hi,

I have a gridview that has some rows in a UpdatePanel, there is also a button that proceeds into another updatepanel. I add the gridview rows in an arraylist in the button_click event. How can I pass this arraylist to another function?
protected void Button_Click(object sender, EventArgs e)
        {
            
            string number;

            foreach (GridViewRow row in GridViewRCC.Rows)
            {
                //GridViewRCC.AllowPaging = false;
                number = GridViewRCC.DataKeys[row.RowIndex].Value.ToString();

                Recipients.Add(number);
            }
            updatePnl.Visible = true;
            UpdatePanel1.Visible = false;
            UpdatePanelSearch.Visible = false;
        }


 public void XXXX()
 {
//here I wan't to get the recipients arraylist....
}

Open in new window

0
Comment
Question by:mattegol
  • 6
  • 5
11 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34211631
You don't appear to declare "Recipients" in your click event, which suggests yuo have it defined at the page level somewhere. In which case you should simply be able to access directly, just as you do from the Click event handler.
0
 

Author Comment

by:mattegol
ID: 34211665
I have declared it: ArrayList Recipients = new ArrayList(); above Page_Load

I have used a session to make it work, but I dont know if thats the best way to go..?

first
Session["Recipients"] = (object)Recipients;

Then
ArrayList arr1 = new ArrayList();
                arr1 = (ArrayList)Session["Recipients"];
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 34211671
If you need to hold on to that list between page requests then storing it in the session is a perfectly valid option.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:mattegol
ID: 34211752
Ok, I'll go for the session then. Should I end the session somehow? because there will be a lot of sessions when hundreds of users are using this.
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34211788
The sessions will end by themselves after a period of inactivity, 20 minutes by default.
0
 

Author Comment

by:mattegol
ID: 34211873
Yes I know but won't the hundreds of sessions effect the performance of the page?
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 500 total points
ID: 34211893
It depends how much data you are planning to hold in the session. It won't affect the page itself, but it will affect the amount of memory being used on the server (if you're using InProcess state rather than a StateServer or SQL solution)

Do you need access to your arraylist across page requests? Can you safely clear it out again after your call to XXX()?
0
 

Author Comment

by:mattegol
ID: 34211920
I think it will be safe to clear it out after. I have a second button that will use the session but then it could be ended. It should not be ended to early because there is a go back..
0
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 500 total points
ID: 34211928
You don't need to actually end the session, just clear out the variable.

i.e.
Session.Remove("Recipients")

Open in new window

0
 

Author Comment

by:mattegol
ID: 34212172
Ok, how about the points?  where should i award them :)
0
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 34212179
Wherever you like :) you can split across multiple posts if you like, but the net result will be the same.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question