提交期间未发布的复选框列表的值

Values of List of checkboxes not posted during submit

我设法显示了 2 行复选框,第 2 行最初在 cshtml 视图中被选中。但是在我更改视图上的选择并提交后,发布的数据并没有反映当前的选择。它仍然显示页面构建时的初始状态。请帮忙谢谢

我有这样的数据模型:

public class Check
{
    public List<CheckModel> chkList = new List<CheckModel>()
    {
        new CheckModel("1",false),
        new CheckModel("2",true)
    };
}

public class CheckModel
{
    public string name{get;set;}

    public bool choice{get;set;}

    public CheckModel(string nn, bool bb)
    {
        name=nn;
        choice=bb;
    }

}

View是这样的:

@model 检查

@using (Html.BeginForm("abcde","主页", FormMethod.Post)) {

<ul>
    @for(int i=0; i < Model.chkList.Count;i++)
    {
        <li>
            input type="checkbox" asp-for=@Model.chkList[i].choice/>@Model.chkList[i].name
        </li>
    }
</ul>


<input type="submit" value="submit"/>

}

Homecontroller.cs :

public IActionResult abcde(Check c)
{
    return Ok();
}

chkList 应该是 属性

public class Check
{
    public List<CheckModel> chkList { get; set; } = new List<CheckModel>()
    {
        new CheckModel("1",false),
        new CheckModel("2",true)
    };
}

public class CheckModel
{
    public string name { get; set; }

    public bool choice { get; set; }

    public CheckModel(string nn, bool bb)
    {
        name = nn;
        choice = bb;
    }

    public CheckModel()
    {

    }
}