Solved

How to pass arraylist between updatepanels

Posted on 2010-11-25
11
364 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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!
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now