You can use multiple models in a single view by creating a common model for all the models that are to be used in a single view. To achieve this, refer to the following steps.
First, create a new model (common for all models) and refer all other models that are to be used in the same view. Refer to the following code example.
Next, create controller and pass the common model to it. Refer to the following code example.
In View page, refer only to the common model file. Then, you can differentiate the models by using the variables that are created in the common model file.
For example, for first model you can refer to the model as model.ListModel1. Refer to the following code example.
Likewise you can differentiate the models in a single view.
The following screenshot illustrates the output.
Figure 1: Multiple models in a single view
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:|