[英]How to access Dictionary Model Property value from View - ASP.Net MVC
I want to get value of Dictionary from View.我想从视图中获取字典的价值。 In the view, I have a main/first foreach loop that retrieve data from Model, and inside the main/first loop , I need to retrieve the ListAttribute value according to the first loop by Id.
在视图中,我有一个从 Model 检索数据的主/第一个foreach 循环,在主/第一个循环内,我需要根据 Id 的第一个循环检索ListAttribute值。
**//Code in the View - First loop to retrieve data from Model**
@model IEnumerable<ABC.Web.Models.Room.Housing>
foreach (var item in Model.OrderBy(x => x.Id))
{
<div class="col-xs-18 col-sm-4">
<div class="thumbnail">
*...(remainer of the code)*
//Here to insert second loop to retrieve *ListAttribute*
}
//Code in the Model
namespace ABC.Web.Models.Room
{
public class Housing
{
public string[] FloorPlan { get; set; }
public Dictionary<string, ListAttribute> ListAttributes { get; set;}
public string Latitude { get; set; }
}
public partial class ListAttribute
{
public string name { get; set; }
public string icon { get; set; }
public string value { get; set; }
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.