Click here to Skip to main content
15,893,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

how can I add an array to a session? is there a way to do it? heres my code:

protected void CompetencyRetrieve(object sender, EventArgs e)
   {
       int index = Convert.ToInt32(maxindex.Text); // ERROR HERE

           DropDownList box1 = (DropDownList)Gridview1.Rows[index].Cells[1].FindControl("DropDownList1");
           DropDownList box2 = (DropDownList)Gridview1.Rows[index].Cells[2].FindControl("DropDownList2");
           DropDownList box3 = (DropDownList)Gridview1.Rows[index].Cells[3].FindControl("DropDownList3");

           var Trainings = DataService.Instance.getTraining(box2.Text, box1.Text);
           if (Trainings.Rows.Count != 0)
           {
               box3.DataSource = Trainings;
               box3.DataTextField = "ProgramsDesc";
               box3.DataValueField = "Programs_id";
               box3.DataBind();

               //session here

           }
           else
           {
               box3.Items.Clear();
           }


   }


each time that this function triggers, an entry to the array will be added, then stored inside a session. any help?
Posted
Comments
BillWoodruff 13-Nov-13 9:46am    
Please clarify exactly what you mean by "session" are you speaking of "saving state" in a user's ASP.NET web-site session; or, are you speaking of how to save the values in an array between a user running an application ? ... or ?

1 solution

Try this
may be this will help you..
To store all items of the array.
C#
string[] a = new string[]{"a","b","c"};
Session["values"] = a;

And in the next page, you can retrieve it like this.
C#
string[] a = (string[])Session["values"]
 
Share this answer
 
v2

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