Click here to Skip to main content
15,896,344 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Need to transfer the array values from one click event to another.
How is it possible?

I have tried ViewState but it is useful only for transfering single value not array.
:(
Here is my Code:

C#
String[] Id_To = new String[10];
 protected void CheckButton_Click(object sender, EventArgs e)
    {
        foreach (ListItem item in CheckBoxList1.Items)
        {
            if (item.Selected)
            {
                i++;
                Id_To[i] += item.Value.ToString();
            }
        }
    }


I need to transfer the content stored in Id_To into another click event of SendButton_Click.

C#
protected void SendButton_Click(object sender, EventArgs e)
    {
      
    }


How is it possible?
Posted
Updated 29-Mar-11 18:48pm
v3
Comments
#realJSOP 29-Mar-11 14:14pm    
What array values?
Sandeep Mewara 29-Mar-11 15:16pm    
Not clear. Can you edit the question try to be more clear on what are you trying to do?

Check the sample..
C#
protected void Page_Load(object sender, EventArgs e)
{
 String[] myArray = { "1", "4", "5", "6", "7" };
 Session["arr"] = myArray;
}
protected void SendButton_Click(object sender, EventArgs e)
{
//you will have the myarray values in test.
String[] test = (String[])Session["arr"];
}


From your code as you want to use the array in session in CheckButton_Click event without happening of this event if you click on SendButton the session will be null.
 
Share this answer
 
v2
Comments
naveen.0nick 30-Mar-11 1:50am    
i have used required field validation for that. :)
store that array value in session["Array"]

use that in other event and then

clear that session
 
Share this answer
 
Comments
naveen.0nick 30-Mar-11 0:47am    
Sorry but can u also tell me how to store array values inside session. When i am trying your solution only one value is getting added not all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900