我的 Html-BeginForm 正在向我的控制器传递空值

My Html-BeginForm is passing null values to my controller

我有这张表格

@using (Html.BeginForm("SearchSubmit", "Search", FormMethod.Post))
{
    <fieldset>
        @Html.DropDownListFor(a => a.Item2.CategoryName, new SelectList(Model.Item1.Categories), "All Categories", new { @class = "makeHigh" })
        @Html.DropDownListFor(a => a.Item2.MarketCategoryName, new SelectList(Model.Item1.Markets), "All Markets", new { @class = "makeHigh" })
        <br />
        @Html.DropDownListFor(a => a.Item2.ColumnName, new List<SelectListItem> {

                       new SelectListItem { Value = "0" , Text = "Item Title" },
                       new SelectListItem { Value = "9" , Text = "Search All" },
                       new SelectListItem { Value = "1" , Text = "Description" },
                       new SelectListItem { Value = "2" , Text = "Upc" },
                       new SelectListItem { Value = "3" , Text = "Sku" },
                       new SelectListItem { Value = "4" , Text = "Brand" },
                       new SelectListItem { Value = "5" , Text = "Size" },
                       new SelectListItem { Value = "6" , Text = "Location" },
                       new SelectListItem { Value = "7" , Text = "Price" },

                    }, new { @class = "makeHigh" })

        @Html.DropDownListFor(a => a.Item2.ValueExpression, new List<SelectListItem> {
                       new SelectListItem { Value = "0" , Text = "Contains" },
                       new SelectListItem { Value = "1" , Text = "Equals Exactly" },
                       new SelectListItem { Value = "2" , Text = "Contains Partial" },
                    }, new { @class = "makeHigh" })
        @Html.TextBoxFor(a => a.Item2.SearchQuery, new { @class = "makeWide" })<br />

        <button class="btn-dark btn-sm btn-info" type="submit">Search</button> 
    </fieldset>
}

当我点击提交按钮时,它将空值传递给我的控制器操作

   [HttpPost]
    public IActionResult SearchSubmit(SearchFormModel search) {

       var results =  _assets.searchInventoryAssets(search.SearchQuery, search.CategoryName, search.MarketCategoryName, search.ColumnName, search.ValueExpression);
       return RedirectToAction("Index", new { assets = results });
    }

我不确定为什么没有发送表单中的数据

Item2 是模型@model 元组;

searchformmodel 看起来像这样

    public string SearchQuery { get; set; }
    public string CategoryName { get; set; }
    public string MarketCategoryName { get; set;  }
    public string ColumnName { get; set; }
    public string ValueExpression { get; set; }

你的 viewmodel 应该是 SearchFormModel,而不是 Tuple, 或更改您的 Controller Action 以期待 Tuple.