I have some trouble understanding checkboxes in asp.net MVC. I am trying to display a list of objects and adding a checkbox to each object. I just don't know which kind of checkbox to use.
I created checkboxes with usual html or razors @html.checkbox/checkboxfor but I don't know how to connect them to the object.
I want to choose some of the listed objects and in a second step display only those.
Can someone explain to me which checkbox I should use and how to connect them to the object?
The objects have an id with which we could connect the Checkbox.
I googled a lot but couldn't find a proper Explanation for the use checkboxes in asp.net mvc.
View
@model List<Person>
@{
ViewBag.Title = "ShowView";
}
@foreach (var element in Model)
{
/*Checkbox*/ <p>@Html.DisplayFor(m => element.Name)</p>
}
Model
public class Person
{
public string Name { get; set; }
public string Path { get; set; }
public long Size { get; set; }
public DateTime LastChange { get; set; }
public int Id { get; set; }
public Project(string name, string path, long size, DateTime lastChange, int id)
{
this.Name = name;
this.Path = path;
this.Size = size;
this.LastChange = lastChange;
this.Id = id;
}
}
Aucun commentaire:
Enregistrer un commentaire