in cshtml::
Define webgrid::
@model ExcelMigration.WEB.ViewModel.BuroCustomerInfoViewModel
@{
ViewBag.Title = "Verify Excel Data";
Layout = "~/Views/Shared/_Layout.cshtml";
var rowCount = Model.CheckStaffDataTable.Count();
WebGrid grid = new WebGrid(Model.CheckStaffDataTable, rowsPerPage: rowCount == 0 ? 1 : rowCount);
Model.BranchCode = Session["BranchCode"].ToString() != null ? Session["BranchCode"].ToString() : null;
Model.IsSuperAdmin = Convert.ToBoolean(Session["IsSuperAdmin"].ToString() != null ? Session["IsSuperAdmin"].ToString() : "false");
}
Define webgrid::
@model ExcelMigration.WEB.ViewModel.BuroCustomerInfoViewModel
@{
ViewBag.Title = "Verify Excel Data";
Layout = "~/Views/Shared/_Layout.cshtml";
var rowCount = Model.CheckStaffDataTable.Count();
WebGrid grid = new WebGrid(Model.CheckStaffDataTable, rowsPerPage: rowCount == 0 ? 1 : rowCount);
Model.BranchCode = Session["BranchCode"].ToString() != null ? Session["BranchCode"].ToString() : null;
Model.IsSuperAdmin = Convert.ToBoolean(Session["IsSuperAdmin"].ToString() != null ? Session["IsSuperAdmin"].ToString() : "false");
}
Add Styles:: <style type="text/css">
.webgrid-table {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 1.2em;
width: 100%;
display: table;
border-collapse: separate;
border: solid 1px #98BF21;
background-color: white;
}
.webgrid-table td, th {
border: 1px solid #98BF21;
padding: 3px 7px 2px;
}
.webgrid-header {
background-color: #A7C942;
color: #FFFFFF;
padding-bottom: 4px;
padding-top: 5px;
text-align: left;
}
.webgrid-footer {
}
.webgrid-row-style {
padding: 3px 7px 2px;
}
.webgrid-alternating-row {
background-color: #EAF2D3;
padding: 3px 7px 2px;
}
</style>
Call::
@using (Html.BeginForm("VerifyExcelData", "ExcelUpload", FormMethod.Post, new { enctype = "multipart/form-data", @role = "form" }))
{
<div class="row frmRow">
<div class="col-md-6 col-sm-6">
<div class="item form-group">
<label class="control-label col-md-4 input-sm"> </label>
<div class="col-md-8">
<button type="submit" class="btn btn-sm btn-success" id="btnCheck">Verify Data</button>
</div>
</div>
</div>
</div>
}
Backed end::
view Model:: Add this Property.
public List<dynamic> CheckStaffDataTable { get; set; }
Call This Function::
[HttpPost]
public ActionResult VerifyExcelData(BuroCustomerInfoViewModel entity)//string Id, string Center
{
var list = new List<dynamic>();
MapBranchCodeList(entity);
try
{
if (entity.BranchCode != "" && entity.SpName != "")
{
if (entity.DateTo != "" && entity.DateTo != null)
{
list = SpDynamicCalling(entity.BranchCode, entity.DateTo, entity.SpName);
}
else
{
list = SpDynamicCalling(entity.BranchCode, entity.SpName);
}
}
entity.Result = 1;
entity.ReturnMessage = "";
}
catch (Exception e)
{
entity.Result = 2;
entity.ReturnMessage = "You provided wrong parameter for this check.";
}
entity.CheckStaffDataTable = list.Count > 0 ? list : new List<dynamic>();
return View(entity);
}