0
这是一个简单的问题,但我一直在努力。我只想发送一个参数,这是一个int数组到我的ActionResult。每次我尝试过它都会返回为空。如何将一个int数组传递给一个ActionResult?
查看:
@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);
}
我想通过在ReviewPeriodID
在标记中,您有'ReviewPeriodIDs'以's'结尾,而动作期望'ReviewPeriodID'没有's'。您也可能需要格式化它,所以隐藏字段中的值实际上看起来像'value1,value2,value3' – Andrei
嗨,我不认为标记会很重要,因为我不使用它将值提交给表单。埃尔戈我不认为那个隐藏的领域会很重要。 –