控制器代码:
DataSet userlist = db.Query("SELECT ID,UserName FROM [dbo].[User]"); ViewBag.userlist = userlist;
View视图页代码:
@foreach (System.Data.DataRow items in (ViewBag.userlist as System.Data.DataSet).Tables[0].Rows) { if (items["ID"].ToString() == item.applyman.ToString()) { @items["UserName"] } }
完美解决!