在我的獲取/索引視圖中我張貼到我的發佈/索引方法在holidayController。 所以我張貼在用戶名,我怎樣才能使用它來訪問用戶名?有userID在視圖中,需要userName張貼
㈣試圖
public ViewResult Index(int userID, string userName)
{
Person person = new Person();
//this assigns person.Id to the user Id
person.Id = userID;
//i want to assign name of person to the string userName
userName = person.name;
}
這是閃動起來不能爲空值person.name?
你爲什麼要這麼做?我認爲你在這裏是錯誤的方向... –
你使用默認的內置aspnetdb? – garfbradaz
@Pabloker,你是感謝您的答覆正確的,我是在錯誤的方向,使用LINQ我得到它到底:人的人(在db.People 從p其中p.Id == HolidayDate 選擇P)=。 FirstOrDefault(); userName = person.Name; – John