Showing posts with label Use of Model using strongly view in MVC. Show all posts
Showing posts with label Use of Model using strongly view in MVC. Show all posts

Thursday, 21 November 2013

Use of Model using strongly view in MVC

Use of Model using strongly view in MVC

In my last article I discussed model in a simply way. In this example I am going to explain model using strongly view.

For this example I am taking the previous example in which I have created the model class named EmployeeData.

In this example after creating the model class, create view where you want to use this model. So go to index method->right click on it->add view.



Figure 1

In this view check the option creates a strongly-typed view and selects your model from dropdownlist.

Note: - sometime it happened that model class do not show in dropdownlist. In this situation kindly build your project and then again try.

After adding this view you can see that it automatically added @model object for this 
class which you provided in strongly view.

Now create the object of this class in index method, assign data to the variable and then pass this object to the view.