我正在使用Asp.Net和JqueryMobile(C#)。我声明string [] roomno = new string [100];在我的课堂上。
在Page_load事件: -
if (!Page.IsPostBack)
{
Some Code...
for (int j = 0; j <= vallen; j++)
{
roomno[j] = "A" + Convert.ToString(j + 1);
}
Some Code,..
}
当我单击按钮时数组值清晰。所以我想知道如何在View State中保存数组?并在ASP.NET中检索它?
ViewState["some_key"] = roomno;
roomno = ViewState["some_key"] as string[];
或者说那个效果:)
ViewState["SomeKey"] = (string[])roomno;
roomno = (string[])ViewState["SomeKey"];
或者初始化
string[] roomno = string[0];
ViewState.Add("SomeKey", roomno);