首先建立一公用函数,用于取出URL中的值
#region "读取页面参数"
/// <summary>
/// 返回页面传送参数
/// 傅威编写
/// 2006-08-08
/// </summary>
///<param name="strPara">获取值页面</param>
/// <param name="strPara">参数名称</param>
/// <returns>返回值</returns>
public static string GetParameter(Page page, string strParaName)
{
string strVal = "";
if (page.Request.QueryString[strParaName] != null)
{
strVal = page.Request.QueryString[strParaName];
}
return strVal;
}
#endregion
然后在调用页面,将读取出来的值放入viewstate里
如:
private long MonthPlanID
{
get
{
string strVal = "";
if (ViewState["MonthPlanID"] == null || ViewState["MonthPlanID"].ToString() == "")
{
strVal = ComFunction.GetParameter(Page, "MonthPlanID");
ViewState["MonthPlanID"] = strRepID;
}
else
{
strVal = ViewState["MonthPlanID"].ToString();
}
return Convert.ToInt64(strVal);
}
}