リストボックス内の項目を別のページの別のリストボックスに運ぶリストボックスが1つのページにありますが、2番目のリストボックスに「System.Collection.ArrayList」が表示されます。
ページ1:
protected void btnCheckout_Click(object sender, EventArgs e)
{
Session["Name"] = NameText.Text;
Session["PhoneNumber"] = PhoneTextBox.Text;
Session["Address"] = AddressText.Text;
Session["Email"] = emailText.Text;
Session["City"] = cityTextBox.Text;
ArrayList al = new ArrayList();
for (int i = 0; i < ItemListBox.Items.Count; i++)
{
if (ItemListBox.Items[i].Selected == true)
{
al.Add(ItemListBox.Items[i].Value);
}
}
Session["selectedValues"] = al;
Response.Redirect("Invoice.aspx");
}
ページ2:
protected void Page_Load(object sender, EventArgs e)
{
string phoneNumber = (string)(Session["PhoneNumber"]);
string homeAddress = (string)(Session["Address"]);
string name = (string)(Session["Name"]);
string email = (string)(Session["Email"]);
string city = (string)(Session["City"]);
phoneLabel.Text = phoneNumber;
addressLabel.Text = homeAddress;
nameLabel.Text = name;
emailLabel.Text = email;
cityLabel.Text = city;
invoiceListBox.Items.Add(Session["selectedValues"].ToString());
}
他のすべてのラベル セッションは動作します。動作しないのはリスト ボックスのみです。