I am uploading an excel with data more than 2 lacs rows. Dividing into chunks of 500 rows everytime to create xml and hit the database , after processing using stored procedure i am returning the updated 500 rows and storing in a datatable and appending every 500 rows returned upto 2 lacs rows are processed.
Its working fine i get a datatable of 2 lacs processed rows. Now when i am reurning this Datatable to the View to display it throws Out Of Memory Exception.
Please help.
Controller :
return View(validateDS.Tables[0]);
View:
@model System.Data.DataTable
@using System.Data;
<h2>Upload File</h2>
@using (Html.BeginForm("Index", "Upload", null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary()
<div class="form-group">
<input type="file" id="dataFile" name="upload" />
</div>
<div class="form-group">
<input type="submit" name="Command" value="Upload Cegedim" class="btn btn-default" />
</div>
if (Model != null)
{
<table>
<thead>
<tr>
@foreach (DataColumn col in Model.Columns)
{
<th>@col.ColumnName</th>
}
</tr>
</thead>
<tbody>
@foreach (DataRow row in Model.Rows)
{
<tr>
@foreach (DataColumn col in Model.Columns)
{
<td>@row[col.ColumnName]</td>
}
</tr>
}
</tbody>
</table>
}
}
What I have tried:
I have tried the above code. It worked fine for 50k records. now its not working for 2 lac records.
I know .Net provides only 2GB of data but there must be a work around for such situations Please help.
1) I also want to know how can i apply paging in this situation with the above code.