以下是错误信息:
未能加载视图状态。正在向其中加载视图状态的控件树必须与前一请求期间用于保存视图状态的控件树相匹配。例如,当以动态方式添加控件时,在回发期间添加的控件必须与在初始请求期间添加的控件的类型和位置相匹配。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: 未能加载视图状态。正在向其中加载视图状态的控件树必须与前一请求期间用于保存视图状态的控件树相匹配。例如,当以动态方式添加控件时,在回发期间添加的控件必须与在初始请求期间添加的控件的类型和位置相匹配。源错误:
行 110: ((IReportTableable)ct).compName = Session["UserName"].ToString();
行 111: PH1.Controls.Clear();
行 112: PH1.Controls.Add(ct);
行 113: }
行 114:
下面是部分源代码:
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsLogin())
{
Response.Redirect("../login/login.aspx");
}
if(Session["UserName"] == null)
{
//取企业名称
Caa.Data.CompInfo.comp_infoRow CmpyInfo = Caa.Data.Users.GetCompInfo(this.UserCode);
if(CmpyInfo != null)
{
Session.Add("UserName",CmpyInfo.ccompname);
}
}
if(!this.IsPostBack)
{
DataSet ds = Caa.Data.Report_02item.GetFilledQuarter(this.CurYear,this.UserCode);
this.dropCyear.DataSource = ds;
this.dropCyear.DataBind();
this.DropMonth.DataSource = ds;
this.DropMonth.DataBind();
BindData(Convert.ToInt16(ds.Tables[0].Rows[0]["cyear"]),Convert.ToInt16(ds.Tables[0].Rows[0]["rptmonth"]),Convert.ToInt16(ds.Tables[0].Rows[0]["canedit"]));
}
//wait
//if(Request.QueryString["month"] != "")
//{
// int cyear = Convert.ToInt16(Request.QueryString["cyear"]);
// int month = Convert.ToInt16(Request.QueryString["month"]);
// BindData(cyear,month,0);
//}
//wait
}
//绑定固定的季度表
private void BindData(int cyear,int rptmonth,int isedit)
{
if(isedit == 0)
{
UserContrlReportTable.Report02_itemEdit.canedit = isedit;
UserContrlReportTable.Report02_itemEdit.month = rptmonth;
string tablename = "Report02_itemEdit.ascx";
ct = Page.LoadControl("../UserContrlReportTable//" + tablename);
}
else if(isedit == 1 || isedit == 2)
{
UserContrlReportTable.Report02_item.month = rptmonth;
UserContrlReportTable.Report02_item.canedit = isedit;
string tablename = "Report02_item.ascx";
ct = Page.LoadControl("../UserContrlReportTable//" + tablename);
if(isedit == 1)
{
this.BtEdit.Visible = true;
}
}
((IReportTableable)ct).cyear = this.CurYear.ToString();
((IReportTableable)ct).compCode = this.UserCode;
((IReportTableable)ct).compName = Session["UserName"].ToString();
PH1.Controls.Clear();
PH1.Controls.Add(ct);
}
在线急等!!
谢谢!!
未能加载视图状态。正在向其中加载视图状态的控件树必须与前一请求期间用于保存视图状态的控件树相匹配。例如,当以动态方式添加控件时,在回发期间添加的控件必须与在初始请求期间添加的控件的类型和位置相匹配。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Web.HttpException: 未能加载视图状态。正在向其中加载视图状态的控件树必须与前一请求期间用于保存视图状态的控件树相匹配。例如,当以动态方式添加控件时,在回发期间添加的控件必须与在初始请求期间添加的控件的类型和位置相匹配。源错误:
行 110: ((IReportTableable)ct).compName = Session["UserName"].ToString();
行 111: PH1.Controls.Clear();
行 112: PH1.Controls.Add(ct);
行 113: }
行 114:
下面是部分源代码:
private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsLogin())
{
Response.Redirect("../login/login.aspx");
}
if(Session["UserName"] == null)
{
//取企业名称
Caa.Data.CompInfo.comp_infoRow CmpyInfo = Caa.Data.Users.GetCompInfo(this.UserCode);
if(CmpyInfo != null)
{
Session.Add("UserName",CmpyInfo.ccompname);
}
}
if(!this.IsPostBack)
{
DataSet ds = Caa.Data.Report_02item.GetFilledQuarter(this.CurYear,this.UserCode);
this.dropCyear.DataSource = ds;
this.dropCyear.DataBind();
this.DropMonth.DataSource = ds;
this.DropMonth.DataBind();
BindData(Convert.ToInt16(ds.Tables[0].Rows[0]["cyear"]),Convert.ToInt16(ds.Tables[0].Rows[0]["rptmonth"]),Convert.ToInt16(ds.Tables[0].Rows[0]["canedit"]));
}
//wait
//if(Request.QueryString["month"] != "")
//{
// int cyear = Convert.ToInt16(Request.QueryString["cyear"]);
// int month = Convert.ToInt16(Request.QueryString["month"]);
// BindData(cyear,month,0);
//}
//wait
}
//绑定固定的季度表
private void BindData(int cyear,int rptmonth,int isedit)
{
if(isedit == 0)
{
UserContrlReportTable.Report02_itemEdit.canedit = isedit;
UserContrlReportTable.Report02_itemEdit.month = rptmonth;
string tablename = "Report02_itemEdit.ascx";
ct = Page.LoadControl("../UserContrlReportTable//" + tablename);
}
else if(isedit == 1 || isedit == 2)
{
UserContrlReportTable.Report02_item.month = rptmonth;
UserContrlReportTable.Report02_item.canedit = isedit;
string tablename = "Report02_item.ascx";
ct = Page.LoadControl("../UserContrlReportTable//" + tablename);
if(isedit == 1)
{
this.BtEdit.Visible = true;
}
}
((IReportTableable)ct).cyear = this.CurYear.ToString();
((IReportTableable)ct).compCode = this.UserCode;
((IReportTableable)ct).compName = Session["UserName"].ToString();
PH1.Controls.Clear();
PH1.Controls.Add(ct);
}
在线急等!!
谢谢!!
private void btSearch_Click(object sender, System.EventArgs e)
{
if(verifybutton())
{
BindData(Convert.ToInt16(this.dropCyear.SelectedValue),Convert.ToInt16(this.DropMonth.SelectedItem.Text),Convert.ToInt16(this.DropMonth.SelectedValue));
}
}
求教??
能否给出一个例子!!!