protected void Button2_Click(object sender, EventArgs e)
{
int[] L = { 1, 2, 3, 4, 5 };
ViewState["I"] = L.ToArray();
}
protected void Button1_Click(object sender, EventArgs e)
{
int[] I = { };
if (ViewState["I"] != null)
I = (int[])ViewState["I"];
for (int i = 0; i < I.Length; i++)
Response.Write(I[i].ToString());
}
当我运行程序时,发生错误:如何将数组存储在asp.net中的ViewState中?
无法转换 类型的对象 'System.Collections.Generic.List`1 [System.Int32]' 为类型“系统。 INT32 []”。
为什么会发生此错误?
嗨。我做到了,但没有奏效。 – vmahdavi 2011-02-06 18:09:05