1

所以我在列表和绑定方面遇到了问题。如果我有一个字符串名称与另一个列表相似的列表。第一个不绑定;

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    [HttpPost]
    public ActionResult Index(HomeModel model)
    {
        return View();
    }
}

public class HomeModel
{
    public List<string> Test { get; set; }
    public List<string> Tests { get; set; }
}

在视图上

@using(Html.BeginForm())
{
    @Html.TextBoxFor(c => c.Test[0])
    <br/>
    @Html.TextBoxFor(c => c.Tests[0])
    <br />
    <input type="submit"/>
}

第一个测试永远不会在回发时获得任何绑定到它的数据。您必须将名称更改为 Tezt 或其他名称。有人见过这个吗?

4

0 回答 0