我已经习惯了 httpRuntime maxRequestLength =" 99898989" targetFramework =" 4.5"在webconfig上 但它不适用于超过2k的绑定gridview的记录。下面提到的错误:
类型的异常' System.OutOfMemoryException'被扔了。 异常详细信息: System.OutOfMemoryException:类型' System.OutOfMemoryException'的异常被抛出。[ArgumentException:错误序列化值' System.Data.DataSet'类型' System.Data.DataSet。'] System.Web.UI.ObjectStateFormatter.SerializeValue(SerializerBinaryWriter writer,Object value)+3499 System.Web.UI.ObjectStateFormatter.Serialize(Stream outputStream,Object stateGraph)+144 System.Web.UI.ObjectStateFormatter.Serialize(Object stateGraph,Purpose purpose)+71 System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter2.Serialize(Object state,Purpose purpose)+13 System.Web.UI.Util.SerializeWithAssert(IStateFormatter2 formatter,Object stateGraph,目的用途)+40 System.Web.UI.HiddenFieldPageStatePersister.Save()+106 System.Web.UI.Page.SavePageStateToPersistenceMedium(Object state)+ 108System.Web.UI.Page.SaveAllState()+606 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
checkLogin();
//Check User Login
}
}
public void checkLogin()
{
name = System.Web.HttpContext.Current.User.Identity.Name.ToString();
DataSet ds = mrbrbal.getUserDetails(name.ToUpper().ToString());
if (ds.Tables[0].Rows.Count > 0)
{
else if (ds.Tables[0].Rows[0]["UserType"].ToString().ToUpper() == "PROCESSOR")
{
bindAllMRBRReport();
btnSubmitRejectByProcessor.Visible = true;//pop up reject
btnResumeMail.Visible = true;
btnHoldInvoices.Visible = true;
btnRejectInvoice.Visible = false;
}
}
else
{
bindAllMRBRReportByName(name);
btnSubmitReject.Visible = true;//reject button
}
}`
public void bindAllMRBRReport() {
ds = mrbrbal.getAllMRBRReport();
if (ds.Tables[0].Rows.Count > 0)
{
gvMRBRReport.DataSource = ds;
ViewState["Paging"] = ds;
ViewState["Total"] = ds.Tables[0].Rows.Count;
gvMRBRReport.DataBind();
}
}
`
答案 0 :(得分:0)
为gridview使用分页.20K很多!
答案 1 :(得分:0)
尝试将Error serializing value 'System.Data.DataSet' of type 'System.Data.DataSet
对象保存到ds
中导致错误消息ViewState
:
ViewState["Paging"] = ds;
你应该从不尝试将如此庞大而复杂的对象放入ViewState ,因为这样做意味着创建了复杂对象的基于文本的表示(即“序列化”部分)错误),然后将那个巨大的文本放在ViewState
中,然后发送到浏览器(!),这实际上是不安全和无用的 - 除了它生成这么多文本的事实你的应用程序崩溃了。
如果您需要保留DataSet
的副本,请将其放入Session
对象,或使用某种缓存解决方案,例如HttpContext.Cache
。