2016-10-02 48 views

回答

0

在你modelView添加一個名爲FullName的字符串屬性,

模型觀察;

public string FullName {get;set;} 

然後在控制器獲得由UserID用戶,

public ActionResult Index(){ 
    User User = DbContext.User.Where(x => x.UserID == something).FirstOrDefault(); // gets the user by ID 
    modelView model= new modelView(); 
    model.FullName = User.Name + " " + User.LastName; // set Full name 
    return View(model); // return model to razor 
} 

希望幫助,

相關問題