1, the controller in the Action code:
Public class Homecontroller:controller { public actionresult Detail (int ID) { = masterbll.queryone (x = x). StudentID = = ID); // Main Table Userslave slave = slavebll.queryone (x = X.studentid = = ID); // from the table return View (tuple.create (master, slave)); } }
A tuple is a new feature of c#4.0.
If three is returned, Tuple.create (master, slave1, Slave2)
2. View Code:
@{Layout=NULL;} @model Tuple<model.userinfo, model.userslave><! DOCTYPE html>'Viewport'Content='width=device-width,initial-scale=1.0'>@Html. Displayfor (Model=model. Item1.name)</td> </tr> <tr> <td><span> Email </span></td> &l T;td>@Html. Displayfor (Model=model. Item2.email)</td> </tr> </table></body>Model. ITEM1 represents the entity model Userinfo,model. ITEM2 represents the Entity model Userslave
If it is a TextBox control, the same way:
New " name " " - " })
The ASP. NET MVC action returns multiple model entities to the view