想要在一個視圖中使用兩個模型。我有兩個控制器,一個爲當前用戶asp.net mvc 3 razor一個視圖中的兩個控制器
public class ProfileModel
{
public int ID { get; set; }
public decimal Balance { get; set; }
public decimal RankNumber { get; set; }
public decimal RankID { get; set; }
public string PorfileImgUrl { get; set; }
public string Username { get; set; }
}
和第二的firends
public class FriendsModel
{
public int ID { get; set; }
public string Name { get; set; }
public string ProfilePictureUrl { get; set; }
public string RankName { get; set; }
public decimal RankNumber { get; set; }
}
剖面模型總是包含一個項目和朋友模型包含列表
我已經包含兩種型號新型號:
public class FullProfileModel
{
public ProfileModel ProfileModel { get; set; }
public FriendsModel FriendModel { get; set; }
}
我試圖填充這樣FullProfile模型
List<FriendsModel> fmList = GetFriendsData(_UserID);
FullProfileModel fullModel = new FullProfileModel();
fullModel.ProfileModel = pm;
fullModel.FriendModel = fmList.ToList();
但視覺工作室給出.ToList()錯誤
錯誤:
Cannot implicitly convert type 'System.Collections.Generic.List<NGGmvc.Models.FriendsModel>' to 'NGGmvc.Models.FriendsModel'
請諮詢我的東西我怎麼能在單個視圖中顯示兩個型號。
p.s.即時通訊使用MVC3 Razor視圖引擎
感謝