我正在使用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中检索它?
答案 0 :(得分:4)
ViewState["some_key"] = roomno;
roomno = ViewState["some_key"] as string[];
或者说这样的话:)
答案 1 :(得分:0)
ViewState["SomeKey"] = (string[])roomno;
roomno = (string[])ViewState["SomeKey"];
或初始化
string[] roomno = string[0];
ViewState.Add("SomeKey", roomno);