Returning specific table data from the view to the controller? asp.net MVC -


so have view displaying table of data database select/selectall checkbox in place. i'd able list of customernumbers , whether or not have been checked , return controller further action.

enter image description here

below how view written. have tried numberous ways work , stumped.

@model massinactiveinspections.models.customerinfolist  <div class="container">     <h2>@viewbag.title</h2>     <div class="bs-callout bs-callout-info" style="margin-bottom: 0px;">     </div>     <div class="col-md-8">              @using (html.beginform("selectedcustomers", "home", new { returnurl = viewbag.returnurl }, formmethod.post, new { @class = "form-horizontal", role = "form" }))             {                 @html.antiforgerytoken()                 <hr />                 @html.validationsummary(true)                 <div class="form-group">                     <table class="table table-bordered">                         <tr>                             <th class="active">@html.displayname("select all?")<input type="checkbox" class="select-all checkbox" name="select-all" /></th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().businessname)</th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().customername)</th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().customernumber)</th>                                                           <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().inspectioncycledescription)</th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().lastinspectiondate)</th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().routecode)</th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().routeid)</th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().sitenumber)</th>                             <th>@html.displaynamefor(m => m.customerinfolistview.firstordefault().systemcode)</th>                         </tr>                          @foreach (var item in model.customerinfolistview)                         {                             <tr>                                 <td class="active"> <input id="selected" input type="checkbox" class="select-item checkbox" name="select-item" value="1000" /> </td>                                 <td>@html.displayfor(modelitem => item.businessname)</td>                                 <td>@html.displayfor(modelitem => item.customername)</td>                                 <td>                                     @html.displayfor(modelitem => item.customernumber)                                     @html.hiddenfor(m => m.customerinfolistview.firstordefault().customernumber)                                 </td>                                 <td>@html.displayfor(modelitem => item.inspectioncycledescription)</td>                                 <td>@html.displayfor(modelitem => item.lastinspectiondate)</td>                                 <td>@html.displayfor(modelitem => item.routecode)</td>                                 <td>@html.displayfor(modelitem => item.routeid)</td>                                 <td>@html.displayfor(modelitem => item.sitenumber)</td>                                 <td>@html.displayfor(modelitem => item.systemcode)</td>                             </tr>                         }                     </table>                 </div>                 <div class="form-group">                     <div style="margin-top: 50px">                         <input type="submit" id="btnlost" class="btn btn-primary" value="lost"/>                         <input type="submit" class="btn btn-primary" name="oobbutton" value="oob" />                         <input type="submit" class="btn btn-primary" name="refusedbutton" value="refused" />                     </div>                 </div>                 }     </div> </div> 

and controller

[httppost] public actionresult selectedcustomers(customerinfolist  customernumberlist) {     return view("viewcustomerinfo"); } 

also here javascript checkboxes

[httppost] public actionresult selectedcustomers(customerinfolist customernumberlist) {     return view("viewcustomerinfo"); }           //column checkbox select or cancel $("input.select-all").click(function () {     var checked = this.checked;      $("input.select-item").each(function (index, item) {         item.checked = checked;     }); });  //check selected items $("input.select-item").click(function () {     var checked = this.checked;     console.log(checked);     checkselected(); });  //check selected function checkselected() {     var = $("input.select-all")[0];     var total = $("input.select-item").length;     var len = $("input.select-item:checked:checked").length;     console.log("total:" + total);     console.log("len:" + len);     all.checked = len === total; } }); 

not sure if best way handle added fields wanted hiddenfor helper , returned appropriate controller. help.

 @html.hiddenfor(m => m.additionalcustomerinfolistview[i].customernumber) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -