Answer the question
In order to leave comments, you need to log in
How to output data to ASP.NET MVC view by replacing ID with values?
There is a database, the main works table has connections by id_po and id_server, the servers and programs tables should be used as a set of reference books for further quick filling.
Project on MVC 4. How to make it as a result to display data so that ID_server and ID_PO are replaced by names and display it in the view?
Was
Got what I wanted
Found a way out Did what I wanted
Controller
public ActionResult Content()
{
ViewBag.item = db.WORKS;
return View();
}
@foreach (MvcAudit2.Models.WORKS item in ViewBag.item)
{
<tr>
<td>
@item.DATE
</td>
<td>
@item.SERVERS.NAME_SERVER
</td>
<td>
@item.PROGRAMS.NAME_PO
</td>
<td>
@item.VERSION
</td>
<td>
@item.EXECUTOR
</td>
<td>
@item.NomIZM
</td>
<td>
@item.COMMENT
</td>
<td>
@item.STATYS
</td>
</tr>
}
Answer the question
In order to leave comments, you need to log in
Since the View implementation is a strongly typed view , and given "this dictionary requires a model element of type 'System.Collections.Generic.IEnumerable'" you can try
return View(r.ToList());
and match the fields in the View and make it dynamic, without model binding,
and then go through foreach
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question