Sagar Bandkar

Sagar Bandkar

  • 1.4k
  • 347
  • 48.7k

Get Null Value after Post method

Dec 7 2016 3:50 AM
@using (Html.BeginForm())
{
<section class="content">
<div id="gridDiv" class="panel panel-primary">
<div class="panel-heading">
<h5 style="text-align: left; font-weight: bold">Cost Center List</h5>
</div>
<div class="panel-body table_div">
@Html.Grid(Model).Named("Grid").Columns(columns =>
{
columns.Add()
.Titled("<input name='allChk' type='checkbox' id='checkbox1' />")
.Encoded(false)
.Sanitized(false)
.SetWidth(30)
.RenderValueAs(c => Html.CheckBox("selected", c.Selected, new { @class = "checkBox",name= "Selected"})).SetWidth(100);
columns.Add(c => c.vcCosCode).Titled("Cost Center Code").Filterable(true);
}).WithMultipleFilters()
</div>
</div>
<br />
<br />
<br />
<br />
<input type="submit" value="insert" />
</section>
}
 
Mvc:-
[HttpGet]
public ActionResult GridPartial()
{
var data = db.tblMstCostCenter_COS;
return PartialView(data);
}
[HttpPost]
public ActionResult GridPartial(checkboxdata model)
{
var selectedProductsCount = model.checkboxList.Where(t => t.Selected).Select(a => a.inCosId).ToList();
return View();
}
 
Properties
 
public partial class tblMstCostCenter_COS
{
public int inCosId { get; set; }
public string vcCosCode { get; set; }
public string vcCosName { get; set; }
public string vcCosDesc { get; set; }
public bool Selected { get; set; }
public class checkboxdata
{
public List<tblMstCostCenter_COS> checkboxList { get; set; }
public checkboxdata()
{
checkboxList = new List<tblMstCostCenter_COS>();
}
}
 

Answers (1)