I'm newbies with the language asp.net and I have some difficulties to understand how works the @Html.ListBoxFor
( even if I read the doc ).
In my case I have this:
@Html.ListBoxFor(model => model.groupe.Permissions, new SelectList(Model.permissionList,"Name"))
model.groupe.Permissions
is an empty list of permission and Model.permissionList
a list of permission.
I want to create a multiple select list and foreach option have Id = permission.id
and value = permission.Name
How can I do something like that:
@Html.ListBoxFor(model => model.groupe.Permissions, new SelectList(Model.permissionList, id ="Id", value = "Name"))
here permissionList :
public List<Permission> permissionList { get; set; }
and Permission :
public class Permission
{
public long Id { get; set; }
public string Description { get; set; }
public string Name { get; set; }
}
看到这种希望对您有帮助:
@Html.ListBoxFor(model => model.groupe.Permissions, new MultiSelectList(Model.permissionList, "Id", "Name"))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.