hi,
I got System.OutOfMemoryException, when loading large number of records in mvc 5 application.
controller code:
public ActionResult RunReports(int? id)
{
DomainContext CurrentLoginUser = ActiveDirectory_AccessModel.GetUserDetails(); // Username
GridView gv = new GridView();
var userDetails = (from c in db.SP_GR_Get_Userdetails(CurrentLoginUser.DisplayName)
select c.user_roles).FirstOrDefault();
if (userDetails == null)
{
return RedirectToAction("NoAccess");
}
var runResult = (from c in db.tbl_GR_Reports
where c.Report_ID == id
select c).SingleOrDefault();
TempData["ReportId"] = id;
DataSet ds = new DataSet();
DataTable dt = new DataTable();
if (runResult != null)
{
Microsoft.Practices.EnterpriseLibrary.Data.Database salesworldDbConn = new SqlDatabase(runResult.Db_Connection);
DbCommand cmd = salesworldDbConn.GetSqlStringCommand(runResult.Query);
try
{
ds = salesworldDbConn.ExecuteDataSet(cmd);
}
finally
{
cmd.Dispose();
salesworldDbConn = null;
}
if (ds != null && ds.Tables.Count > 0)
{
dt = ds.Tables[0];
}
}
return View(dt);
}
View Code:
@model System.Data.DataTable
@using System.Data
@{
ViewBag.Title = "RunReport";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@(Html.Kendo().Grid(Model) .Name("grid") .Scrollable(scrollable => scrollable.Virtual(true)) .Columns(columns => { columns.AutoGenerate(column => { column.Width = "100px"; }); }) .HtmlAttributes(new { style = "width: 900px;" }) .Scrollable() .Filterable() .Sortable(sortable => sortable.AllowUnsort(true).SortMode(GridSortMode.MultipleColumn)) | |
.Pageable(pageable => pageable
.PageSizes(true)
)
.Resizable(resize => resize.Columns(true))
.DataSource(dataSource => dataSource
.Ajax()
//.PageSize(20)
.ServerOperation(false)
)
)
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Manas MohapatraPosted Aug 4, 2015, 12:42 AM