I looked around and couldn't find an easy solution.
I've tried @GetUserName
which doesn't work.
I've tried @ { GetUserName
which doesn't work.
There has to be an easy way to call a method from the razor view engine.
It is within a foreach
loop.
I need GetUserName(item.userID)
The below code is in my controller:
[ChildActionOnly]
public string GetUserName(int userID)
{
ProPit_User user = db.ProPit_User.Find(userID);
return user.username;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…