我们正在使用ASP.Net Web应用程序,从vs 2008迁移到vs2013,更新了ajaxtoolkit 4.5,我们在选项卡中使用了ajax tab容器和usercontrols。 在其中一个标签中,我得到了这个无法解决的异常 OutOfMemory 数据网格中只有一条记录。任何人都可以建议我如何解决这个问题。 几天前工作正常,从过去4天开始令我们不安。我非常感谢你的帮助。
我浏览了 google 上的一些帖子,其中一些建议将属性更改为64位或32位,应用程序的设置设置为 AllCPUs 而对于内存不足异常,它现在检索的数千条记录超过2GB或4gb,但只有一行有6-7列,这就是我发布的内容。
例外情况如下。
Exception of type System.Web.HttpUnhandledException was thrown.
Exception of type System.OutOfMemoryException was thrown. System.SystemException System.OutOfMemoryException
at System.String.ToCharArray()
at System.IO.TextWriter.Write(String value)
at System.Web.UI.Page.RenderViewStateFields(HtmlTextWriter writer)
at System.Web.UI.Page.BeginFormRender(HtmlTextWriter writer, String formUniqueID)
at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
at System.Web.UI.HtmlFormWrapper.System.Web.UI.IHtmlForm.RenderControl(HtmlTextWriter writer)
at System.Web.UI.PageRequestManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPages/site.Master" CodeBehind="OrderManagement.aspx.cs" Inherits="UserMaintainance.UserMaintainance.OrderManagement" %>
<%@ Register TagPrefix="ucl" TagName="ucSwapSerial" Src="~/UserControls/SwapSerial.ascx" %>
<ajaxToolkit:ToolkitScriptManager ID="scriptManager" runat="server" ScriptMode="Release"></ajaxToolkit:ToolkitScriptManager>
<asp:UpdatePanel ID="updPnlContainer" runat="server">
<ContentTemplate>
<ajaxToolkit:TabContainer ID="tabContainer" runat="server" ActiveTabIndex="0" AutoPostBack="true" OnPreRender="tabContainer_PreRender" CssClass="Tab" >
<ajaxToolkit:TabPanel ID="TPnlSerialSwap" runat="server" HeaderText="Serial Swap" Font-Bold="true" OnClientClick="swapSerialTabClick">
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanelSwapSerial" runat="server" UpdateMode="Always">
<ContentTemplate>
<ucl:ucSwapSerial ID="ucSwapSerial" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSwapSerialTrigger" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
</ContentTemplate>
</asp:UpdatePanel>
//代码隐藏
protected void tabContainer_PreRender(object sender, EventArgs e)
{
this.TabsContainer_PreRender(sender, e);
}
protected void TabsContainer_PreRender(object sender, EventArgs e)
{
DetermineTabsVisibility();
}
protected void DetermineTabsVisibility()
{
string activeTab;
if (IsPostBack)
{
if (Request.Form[EVENT_TARGET] != null &&
Request.Form[EVENT_TARGET] == (this.Master.FindControl(this.MenuButtonID)).UniqueID)
//make it behave like a new page load
{
this.ActiveTab = this.ActivePanels[0];
//Yan: this line may raises a ArgumentOutOfRange exception in JavaScript, because ActiveTabIndex on client side may not match the server side
//this.TabsContainer.ActiveTab = tp;
this.TabsContainer.ActiveTabIndex = 0;
foreach (AjaxControlToolkit.TabPanel tp in this.TabsContainer.Tabs)
foreach (Control ctr in tp.Controls)
ctr.Visible = (tp.ID == this.ActiveTab);
//Need to call the following method since there is no event handler handling this case senario
SwitchToActiveTab();
return;
}
activeTab = GetActiveTabToChange();
//not new page load and not a changed tab;
//event handler has already handles the control visibility
if (activeTab == this.ActiveTab)
return;
//not new page load but a changed tab
foreach (AjaxControlToolkit.TabPanel tp in this.TabsContainer.Tabs)
foreach (Control ctr in tp.Controls)
ctr.Visible = (tp.ID == activeTab);
this.ActiveTab = activeTab;
//although eventhandler might already handles this (selectedindexchanged, etc.), we still need to switch the tab
SwitchToActiveTab();
return;
}
// else, new page load indeed
if (this.AccessibleTabs != null && this.TabsContainer != null)
{
foreach (AjaxControlToolkit.TabPanel tp in this.TabsContainer.Tabs)
{
tp.Visible = false;
if (this.AccessibleTabs.Contains(tp.ID))
{
tp.Visible = true;
foreach (Control ctr in tp.Controls)
ctr.Visible = true;
}
}
SwitchToActiveTab();
}
else if (this.AccessibleTabs == null || this.AccessibleTabs.Count <= 0)
{
Response.Redirect(Helper.LOGIN_PAGE);
}
}
//Usercontrol
<asp:GridView ID="gvSerialList" runat="server"
DataKeyNames="SerialNumberID" EnableViewState="True" AutoGenerateSelectButton="False" onsorting="gvSerialList_Sorting"
OnPageIndexChanging="gvSerialList_PageIndexChanging"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSerialSelector" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="SerialNumberID" HeaderText="SerialNumber ID" Visible="false" SortExpression="SerialNumberID"/>
<asp:BoundField DataField="ERPLineReference" HeaderText="Line #" Visible="false" SortExpression="ERPLineReference"/>
<asp:BoundField DataField="PartNumber" HeaderText="Brightstar Part #" SortExpression="PartNumber"/>
<asp:BoundField DataField="PartDescription" HeaderText="Part Description" SortExpression="PartDescription"/>
<asp:BoundField DataField="Quantity" HeaderText="Qty" SortExpression="Quantity"/>
<asp:BoundField DataField="SerialNumber" HeaderText="Serial" SortExpression="SerialNumber"/>
<asp:BoundField DataField="SIM" HeaderText="SIM" SortExpression="SIM"/>
<asp:BoundField DataField="SerialStatus" HeaderText="Serial Status" SortExpression="SerialStatus"/>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblTest" runat="server" Text='QtyOnHand'></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="lnkShowQty" runat="server" Text="QtyOnHand"></asp:LinkButton>
<asp:Panel ID="pnlQuantity" runat="server" BackColor="YellowGreen" BorderStyle="Solid"><br /> <br />
<asp:Label ID="lblDisplayHeader" runat="server" Text='<%# "Qty on Hand for Brightstar Part#: " + Eval("PartNumber") + "<br /> <br>                         QtyOnHand       Qty Available"%>'></asp:Label>
<br />
<asp:Label ID="lblDisplay" runat="server"></asp:Label>
<ajaxToolkit:ModalPopupExtender ID="lnkShowQty_ModalPopupExtender" runat="server"
OkControlID="btnDlgClose"
TargetControlID="lnkShowQty"
DynamicServicePath="~/WebServices/UIMaintenanceService.asmx"
DynamicServiceMethod="GetPRSQuantityinHand"
DynamicControlID="lblDisplay"
PopupControlID="pnlQuantity"
DynamicContextKey='<%#Eval("PartNumber") %>'
BackgroundCssClass="modal"
DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<br />
                             
<asp:Button ID="btnDlgClose" runat="server" Text="CLOSE" /> <br /> <br /> </asp:Panel>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<HeaderTemplate>
<asp:Label ID="lblSerialSwap" runat="server" Text='SerialSwap'></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:DropDownList ID="ddlSerialSwap" runat="server" DataSourceID="dsSerialSwap" DataTextField="SerialNumber" DataValueField="SerialNumberID" AutoPostBack="true" onselectedindexchanged="ddlSerialStatus_SelectedIndexChanged" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSearch_Click(object sender, EventArgs e)
{
if (IsValid())
{
try
{
lblJDEOrderID.Text = mpOrderAndSerialResponse.ResponseObject.ERPOrderID.ToString();
lblOrderID.Text = mpOrderAndSerialResponse.ResponseObject.OrderID.ToString();
gvSerialList.DataSource = mpOrderAndSerialResponse.ResponseObject.SerialList;
gvSerialList.DataBind();
SwapSerialMessages(string.Empty, MessageType.None);
}
catch (Exception ex)
{
throw ex;
}
}
}