c# - How to pass an int array to an ActionResult? -


it's simple question, yet 1 i've been struggling with. i'd send parameter int array actionresult. every time have tried comes null.

view:

@using (html.beginform("departmentreportselection", "reports", new {clientid = model.inputparameters[0], supplierid = model.inputparameters[1], reviewperiodid = model.inputreviewperiodids, statuscategoryid = model.inputparameters[2]}, formmethod.post)) {             @html.dropdownlistfor(m => m.categorytypeoptions.first().statuscategoryid, new selectlist(model.categorytypeoptions, "statuscategoryid", "statuscategorydesc"), new { @class = "grdropdown", @id = "reportdd" })             <input type="hidden" name="clientid" value="@model.clientid" />             if (model.typeofreport == 1) {                 <input type="hidden" name="reviewperiodids" value="@model.inputreviewperiodids" />                 <input type="hidden" name="supplierid" value="@model.supplierdata" />             }             else if (model.typeofreport == 2) {                 <input type="hidden" name="reviewperiodids" value="@model.inputreviewperiodids" />             }             else{                 <input type="hidden" name="supplierid" value="@model.supplierdata" />             }              <button type="submit" value="submit" class="btn btn-default standardbutton">filter</button>         } 

actionresult:

 public actionresult departmentreportselection(int clientid, string supplier, int[] reviewperiodid, int? supplierid = null, int? statuscategoryid = null) {             // cut out unnecessary code               return view("departmentbreakdown", departmentmodel);         } 

i'm trying pass in reviewperiodid

fixed.

@using (html.beginform("departmentreportselection", "reports", new { clientid = model.inputparameters[0], supplierid = model.inputparameters[1], statuscategoryid = model.inputparameters[2] }, formmethod.post)) {             @html.dropdownlistfor(m => m.categorytypeoptions.first().statuscategoryid, new selectlist(model.categorytypeoptions, "statuscategoryid", "statuscategorydesc"), new { @class = "grdropdown", @id = "reportdd" })             <input type="hidden" name="clientid" value="@model.clientid" />             if (model.typeofreport == 1) {                 (int = 0; < model.inputreviewperiodids.length; i++) {                     <input type="hidden" name="reviewperiodid" value="@model.inputreviewperiodids[i]" />                 }                  <input type="hidden" name="supplierid" value="@model.supplierdata" />             }             else if (model.typeofreport == 2) {                 (int = 0; < model.inputreviewperiodids.length; i++) {                     <input type="hidden" name="reviewperiodid" value="@model.inputreviewperiodids[i]" />                 }             }             else {                 <input type="hidden" name="supplierid" value="@model.supplierdata" />             }              <button type="submit" value="submit" class="btn btn-default standardbutton">filter</button>         } 

you need create foreach loop in view loop around array , create 3 different input fields. submit action. cannot pass through route values.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -