I have a thousands of rows to retrieve but the error is it exceeds the maxlenghtjson property , so it won't in the future if i have a millions of data's. Can you help me how to fix this with my code. I just want all to display of my data in database.
-My Controller, where i pass my parameters from view.
public JsonResult GetSummaryDetails(string TranNo, string BranchCode)
{
List<SummaryDetails> summaryDetails = new List<SummaryDetails>();
dynamic user = Session["UserProfile"];
var UserID = user[0].UserID.ToString();
var UserCode = user[0].DeptCode.ToString();
summaryDetails = dataAccessLayer1.GetAllSummaryDetails(TranNo,BranchCode);
return Json((summaryDetails), JsonRequestBehavior.AllowGet);
}
-My method in DataAccessLayer
public List<SummaryDetails> GetAllSummaryDetails(string TranNo, string BranchCode)
{
List<SummaryDetails> lstSummaryDetails = new List<SummaryDetails>();
using (SqlConnection con = new SqlConnection(conn))
{
SqlCommand cmd = new SqlCommand("spn_viewSummaryApproval", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TranNo", TranNo);
cmd.Parameters.AddWithValue("@BranchCode", BranchCode);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
SummaryDetails summaryDetails = new SummaryDetails();
summaryDetails.EmployeeName = rdr["EmployeeName"].ToString();
summaryDetails.ActionType = rdr["ActionType"].ToString();
summaryDetails.ActionDateTime = rdr["ActionDateTime"].ToString();
summaryDetails.Remarks = rdr["Remarks"].ToString();
lstSummaryDetails.Add(summaryDetails);
}
con.Close();
}
return lstSummaryDetails;
}
-This is my view where i using DataTable and to pass to the controller.
<script>
$(document).ready(function () {
var dataTable = $('#SummaryTable').DataTable({
"language": {
emptyTable: "No Transaction"
},
ajax: {
url: "@Url.Action("GetSummaryTxn")",
dataType: "json",
retrieve: "true",
processing: "true",
serverSide: "true",
type: "POST",
dataSrc: "",
},
order: [],
columnDefs: [
{
targets: [1],
orderable: false,
}
],
columns: [
{data: "BranchName"},
{
data: "TranNo",
render: function (data, type, row, meta) {
var valueTran = row.TranNo;
var valueBranch = row.BranchCode;
var TranNo = row.TranNo + '<button type="button" id="'+ valueBranch +'" data-value="'+ valueTran+ '" class="btn btn-sm btn-primary btnView"><i class="fas fa-arrow-right"></i></button>'
return TranNo;
},
},
{
data: "TranType"
},
{ data: "RecordStatus" },
{ data: "RequestorName" },
{ data: "RequestDate" },
{ data: "LastApprover" },
{ data: "LastApproveDate" },
{ data: "TranDate" },
]
});
});
</script>