Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1510
'System.OutOfMemoryException' when databinding to 201.293 rows
posted

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.