我有一些类似于这些的视图模型:
public class ResturantViewModel
{
public ResturantViewModel()
{
Clients.Add(new ClientViewModel());
}
public string MyProperty {get;set;}
public IList<ClientViewModel> Clients = new List<ClientViewModel>();
}
public class ClientViewModel
{
public string FirstName {get;set;}
public string LastName {get;set;}
}
在我看来,我有类似的东西:
@foreach(var client in Model.Clients)
{
<tr>
<td>First Name: @Html.EditorFor(item => client.FirstName)</td>
<td>Last Name: @Html.EditorFor(item => client.LastName)</td>
</tr>
}
我想要一个按钮,可以将一些新的空白 ClientViewModels 添加到 ResturantViewModel.Clients 列表,以便它可以在视图中呈现并发布到 Resturant/Create 操作。
提前致谢