After the controller coordinates the data, it is presented to the view to display the data. The controller interacts with the view with one that is viewdata.
In this exercise, insus.net will use it as an example.
Some time ago, Insus.net implemented the practice of transmitting data from the controller to the view, such as:
The DataTable data is shown in the MVC application http://www.cnblogs.com/insus/p/3361182.html
MVC uses non-Entity Framework to display data in view http://www.cnblogs.com/insus/p/3364235.html
MVC uses non-Entity Framework to display data in view (ii) http://www.cnblogs.com/insus/p/3364482.html
"MVC shows detailed records without Entity Framework" http://www.cnblogs.com/insus/p/3366608.html
Even in this article, "MVC 5 display, creation, editing, deletion and other functions practice" http://www.cnblogs.com/insus/p/3372916.html also listed.
In order to demonstrate the use of ViewData to transfer data from the controller to the view, first create an object in the model:
After everything is basically ready, the next step is to go to the topic, create the controller, and refer to the steps:
A different window will open:
To modify the controller name:
Controller detail code, which declares an anonymous object directly in the action of the control and assigns a value. This is a slight value from the database. The highlighted code (#23行) is the focus of the whole picture below.
To create a view below, refer to the steps in (1) step, you need to create a directory, the same as the controller name. This is a different place in the previous versions of MVC 5.
After the "Add Scaffold" window appears, select "MVC 5 View" and click the "Add" button.
The "Add View" window appears, in step (6), give the view name of an action, and in step (7), select an empty (without model).
To write the View code:
Operation Result: