Answer the question
In order to leave comments, you need to log in
How to display request data in View ASP?
Good afternoon, faced such a problem, there is the following controller
DataClasses1DataContext context = new DataClasses1DataContext();
var sostav = context.Teams.Join(context.Transfers,
team=>team.TeamId,
transfer => transfer.TeamId,
(team, transfer) => new { nClub = team.nameClub, idPlayer = transfer.PlayerId });
ViewBag.sost = sostav.ToList();
@foreach (var s in ViewBag.sost)
{
<tr>
<th>@s.nClub </th>
</tr>
}
@foreach (var s in ViewBag.sost)
{
<tr>
<th>@s </th>
</tr>
}
Answer the question
In order to leave comments, you need to log in
Because the data exchange should take place through typed View and models, not ViewBag. If you feel like using ViewBag - cast to specific types and refer to properties. In your case, this will not work - because you were too lazy to create classes and used anonymous hacks. As a result - slightly hurt his forehead.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question