i want to send two model in my view and in other page maybe and need more
controller
ViewBag.Users = db.Users.ToList();
and in View
@using Documentation.Models
@{
var Users = (Documentation.Models.User)ViewBag.Users;
}
<table>
@foreach (var item in Users) {
<tr>
<td>
@Html.DisplayFor(item.username)
</td>
</tr>
}
</table>
but i get no answer , i know my code is not right
i got this error
foreach statement cannot operate on variables of type 'Documentation.Models.User' because 'Documentation.Models.User' does not contain a public definition for 'GetEnumerator'
@Html.DisplayFor(item.username)
will throw an error since you're not using an expression likeitem => item.username
so I suggest you use@Html.Display(item.username)
instead =] – Wychelm@foreach (var item in Users)
or invar Users = (Documentation.Models.User)ViewBag.Users;
– Catalectic