?
Solved

How to pass arraylist between updatepanels

Posted on 2010-11-25
11
Medium Priority
?
371 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

770 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