try this code:
page_1.aspx :coding and explains:
first make one listbox and add some values to an listbox(go to property window and select items and give collection of values in your listbox)
second create one button to pass value in next page.
now try this code:
protected void Button1_Click(object sender, EventArgs e)
{
int n=ListBox1.Items.Count;
string[] arr=new string[n];
for (int i = 0; i < arr.Length; i++)
{
arr[i] = ListBox1.Items[i].ToString();
}
Session["arr"] = arr;
Response.Redirect("Default2.aspx");
}
here i first i find the how many items are have in listbox. so use items count.
second i make one string array and store that listbox values in string array.
third i make one session variable and pass that array value to session. now i navigate next page.
now try to get this listbox values in second page.
Second_page.aspx
-----------------
first i make listbox. and try this code.
coding:
-------
string[] arr;
protected void Page_Load(object sender, EventArgs e)
{
arr = (string[])Session["arr"];
for (int i = 0; i < arr.Length; i++)
{
ListBox1.Items.Add(arr[i].ToString());
}
}
here i declare one array and get that session value from that array. and i add the listbox.
i hope this is useful to you.
take care bye bye...