Hi there !
Why am I getting a 'System.OutOfMemoryException' error while "only" loading 201.293 rows ??
I'm binding to a custom datasource ( just a regular data class ) in-code, behind a search button ... please help !!!( I've turned off the viewstate for the Grid to try to load data faster ... doesn't make any difference ! )
What am I doing wrong ??
protected void _btnSearch_Click(object sender, EventArgs e) { if( (_tbBankanumer.Text == string.Empty) || (_tbHofudbok.Text == string.Empty) || (_tbReikningur.Text == string.Empty) ) { _lblBankanumerHofudbokReikningur.Text = "Please don't leave Bankanúmer, Höfuðbók or Reikningur empty - too much data to export to Excel!"; return; }
//1/1/1753 12:00:00 AM and 12/31/9999
DateTime dagsFra = new DateTime(1753,1,1); DateTime dagsTil = new DateTime(9999,12,31);
string bankanumer = _tbBankanumer.Text.Trim(); string hofudbok = _tbHofudbok.Text.Trim(); string reikningsnumer = _tbReikningur.Text.Trim(); if( _dateDagsetningFra.Value != null ) dagsFra = (DateTime)_dateDagsetningFra.Value; if( _dateDagsetningTil.Value != null ) dagsTil = (DateTime)_dateDagsetningTil.Value;
_transactions = TrackingService.GetAllAKTransactionTracksBySearchCriteria(bankanumer, hofudbok, reikningsnumer, dagsFra, dagsTil); Cache["dataFromGrid"] = _transactions; //I've tried taking this out to check if this matters ... doesn't change anything. I'm caching it so I can export the results to Excel later on !
if (_transactions.Count > 0) { _ugTransactions.DataSource = _transactions; // 201.293 rows _ugTransactions.DataBind(); //this will throw 'System.OutOfMemoryException' !!!!! }
_lblRows.Text = "Færslur úr leit: "; _lblRowCount.Text = _ugTransactions.Rows.Count.ToString();
Logger log = getLoggingDetails("RB Færslur", "Search for data"); TrackingService.LogIntoDatabase(log); _lblBankanumerHofudbokReikningur.Text = String.Empty; }
rgd,EE.
Can you tell me how to enable the Grid's Ajax functionality ? Could you give me an example in code for this ... I'm coming from the WinGrid ( Windows Forms ) and I'm currently very fund of that product.
Have you heard about OutOfMemory exception for only 201.293 rows ??Did you examine my code, was I doing something you wouldn't do ?I've e.g. not databound anything in design mode ( e.g. no ObjectDataSource on the form's designer etc... )Kind regards,EE.
It's very likely that the error is exactly what it states - your web server is running out of memory. Depending on how much data is included in your data objects, and how much memory you have available, this may well be expected . Databinding is the most memory-intenstive task that WebGrid performs, if I recall correcctly.
The first solution I can suggest to minimize the memory used with databinding is to enable the grid's AJAX functionality. This will reduce the number of grid rows created significantly, and is likely to speed up data binding.
If enabling the grid's AJAX isn't enough on its own, then also use the grid's partial databinding functionality (also called 'data windowing"). By using this, you can retrieve the data objects specific to what the grid needs at that moment, which will further reduce the grid's memory usage for data binding. The following article from our online help documentation of NetAdvantage for .NET 2009 Volume 1 provides information on partial databinding wtih WebGrid:Partial Data Binding
I'm still waiting for a reply !!! anybody ????
What am I doing wrong, to get an OutOfMemoryException with these 201.293 rows ??Do I need to enable paging or something ??? How would I do that with the Grid ....
Please help!
This is my Initilize-Layout function:
_ugTransactions_InitializeLayout:------------------------------------------------ protected void _ugTransactions_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e) { e.Layout.Bands[0].AllowSorting = Infragistics.WebUI.UltraWebGrid.AllowSorting.OnClient; e.Layout.Bands[0].AllowColSizing = Infragistics.WebUI.UltraWebGrid.AllowSizing.Fixed; e.Layout.Bands[0].AllowColumnMoving = Infragistics.WebUI.UltraWebGrid.AllowColumnMoving.None;
e.Layout.Bands[0].Columns.FromKey("TransTrackId").Hidden = true; e.Layout.Bands[0].Columns.FromKey("KeyrtIVoruhus").Hidden = true;
e.Layout.Bands[0].Columns.FromKey("Bankanumer").Header.Caption = "Banki"; e.Layout.Bands[0].Columns.FromKey("Bankanumer").Width = 50;
e.Layout.Bands[0].Columns.FromKey("Hofudbok").Header.Caption = "HB"; e.Layout.Bands[0].Columns.FromKey("Hofudbok").Width = 20;
e.Layout.Bands[0].Columns.FromKey("Reikningsnumer").Header.Caption = "Reikningsnúmer";
e.Layout.Bands[0].Columns.FromKey("Faerslulykill").Header.Caption = "Færsulykill"; e.Layout.Bands[0].Columns.FromKey("Faerslulykill").Width = 60;
e.Layout.Bands[0].Columns.FromKey("Upphaed").Header.Caption = "Upphæð"; e.Layout.Bands[0].Columns.FromKey("Textalykill").Header.Caption = "Textalykill"; e.Layout.Bands[0].Columns.FromKey("Tekkanumer").Header.Caption = "Tékkanúmer"; e.Layout.Bands[0].Columns.FromKey("Tilvisun").Header.Caption = "Tilvísun"; e.Layout.Bands[0].Columns.FromKey("Faersludagur").Header.Caption = "Færsludagur"; e.Layout.Bands[0].Columns.FromKey("Innlausnarbanki").Header.Caption = "Innlausnarbanki"; e.Layout.Bands[0].Columns.FromKey("Bunkanumer").Header.Caption = "Bunkanúmer"; e.Layout.Bands[0].Columns.FromKey("TegundInntaks").Header.Caption = "TegundInntaks"; e.Layout.Bands[0].Columns.FromKey("RBMatchStatus").Header.Caption = "RBMatchStatus"; e.Layout.Bands[0].Columns.FromKey("MotBankanumer").Header.Caption = "MótBankanúmer"; e.Layout.Bands[0].Columns.FromKey("MotHofudbok").Header.Caption = "MótHöfuðbók"; e.Layout.Bands[0].Columns.FromKey("MotReikningsnumer").Header.Caption = "MótReikningsnúmer"; e.Layout.Bands[0].Columns.FromKey("MotFaerslulykill").Header.Caption = "MótFærslulykill"; e.Layout.Bands[0].Columns.FromKey("MotTextalykill").Header.Caption = "MótTextalykill"; e.Layout.Bands[0].Columns.FromKey("MotTekkanumer").Header.Caption = "MótTékkanúmer"; e.Layout.Bands[0].Columns.FromKey("MotTilvisun").Header.Caption = "MótTilvísun"; e.Layout.Bands[0].Columns.FromKey("MotBunkanumer").Header.Caption = "MótBunkanúmer"; e.Layout.Bands[0].Columns.FromKey("MotKennitala").Header.Caption = "MótKennitala"; e.Layout.Bands[0].Columns.FromKey("MotNafn").Header.Caption = "MótNafn"; //Mótnafn
e.Layout.Bands[0].Columns.FromKey("AKMatchStatus").Header.Caption = "AKMatchStatus"; e.Layout.Bands[0].Columns.FromKey("AKMatchRunDate").Header.Caption = "AKMatchRunDate"; e.Layout.Bands[0].Columns.FromKey("IBASMatchStatus").Header.Caption = "IBASMatchStatus"; e.Layout.Bands[0].Columns.FromKey("IBASMatchRunDate").Header.Caption = "IBASMatchRunDate"; e.Layout.Bands[0].Columns.FromKey("Reiknnumid").Header.Caption = "Reiknnumid"; e.Layout.Bands[0].Columns.FromKey("MotReiknnumid").Header.Caption = "MótReiknnumid";
e.Layout.Bands[0].Columns.FromKey("Bankanumer").Move(1); e.Layout.Bands[0].Columns.FromKey("Hofudbok").Move(2); e.Layout.Bands[0].Columns.FromKey("Reikningsnumer").Move(3); e.Layout.Bands[0].Columns.FromKey("Faerslulykill").Move(4); e.Layout.Bands[0].Columns.FromKey("Upphaed").Move(5); e.Layout.Bands[0].Columns.FromKey("MotBankanumer").Move(6); e.Layout.Bands[0].Columns.FromKey("MotHofudbok").Move(7); e.Layout.Bands[0].Columns.FromKey("MotReikningsnumer").Move(8); e.Layout.Bands[0].Columns.FromKey("MotKennitala").Move(9); e.Layout.Bands[0].Columns.FromKey("MotNafn").Move(10); e.Layout.Bands[0].Columns.FromKey("Textalykill").Move(11); e.Layout.Bands[0].Columns.FromKey("Tekkanumer").Move(12); e.Layout.Bands[0].Columns.FromKey("Tilvisun").Move(13); e.Layout.Bands[0].Columns.FromKey("Faersludagur").Move(14); e.Layout.Bands[0].Columns.FromKey("Innlausnarbanki").Move(15); e.Layout.Bands[0].Columns.FromKey("Bunkanumer").Move(16); e.Layout.Bands[0].Columns.FromKey("TegundInntaks").Move(17); e.Layout.Bands[0].Columns.FromKey("RBMatchStatus").Move(18); e.Layout.Bands[0].Columns.FromKey("MotFaerslulykill").Move(19); e.Layout.Bands[0].Columns.FromKey("MotTextalykill").Move(20); e.Layout.Bands[0].Columns.FromKey("MotTekkanumer").Move(21); e.Layout.Bands[0].Columns.FromKey("MotTilvisun").Move(22); e.Layout.Bands[0].Columns.FromKey("MotBunkanumer").Move(23); }
and this is the data class I'm binding to if it matters ... public class AKTransactionTrack { private int _transTrackId; private string _bankanumer = String.Empty; private string _hofudbok = String.Empty; private string _reikningsnumer = String.Empty; private string _faerslulykill = String.Empty; private decimal _upphaed; private string _textalykill = String.Empty; private string _tekkanumer = String.Empty; private string _tilvisun = String.Empty; private DateTime _faersludagur; private string _innlausnarbanki = String.Empty; private string _bunkanumer = String.Empty; private string _tegundInntaks = String.Empty; private string _rBMatchStatus = String.Empty; private string _motBankanumer = String.Empty; private string _motHofudbok = String.Empty; private string _motReikningsnumer = String.Empty; private string _motFaerslulykill = String.Empty; private string _motTextalykill = String.Empty; private string _motTekkanumer = String.Empty; private string _motTilvisun = String.Empty; private string _motBunkanumer = String.Empty; private string _motKennitala = String.Empty; private string _motNafn = String.Empty;
private DateTime _keyrtIVoruhus; private string _aKMatchStatus = String.Empty; private DateTime _aKMatchRunDate; private string _iBASMatchStatus = String.Empty; private DateTime _iBASMatchRunDate; private int _reiknnumid; private int _motReiknnumid;}