Strongly typed view is a nice feature of ASP.NET MVC. We can access model properties on that view using strongly typed view and we can bind views with any model.
Now let's create a Strongly Typed View List in MVC.
Step 1: Create a ASP.NET MVC application by selecting Empty Template and add Core Reference for MVC.
Now let's create a Strongly Typed View List in MVC.
Step 1: Create a ASP.NET MVC application by selecting Empty Template and add Core Reference for MVC.
Step 2: Right click on your Model Folder and add a new Class File called 'Student.cs'.
Step 3 : Open your Student.cs file and create a Student property like RollNo, FirstName, LastName.
- public class Student
- {
- public int RollNo
- {
- get;
- set;
- }
- public string StudFirstName
- {
- get;
- set;
- }
- public string StudLastName
- {
- get;
- set;
- }
- }
Step 4: Right click on Controller and new Empty Controller from the Add Scaffold.
Step 5: Give a name to Controller like "StudentController."
Step 6: Open 'StudentController' file and create a list of Student, then assign RollNo, Name etc.
Finally assign the Stud Object to ViewData.Model.
- public ActionResult Index()
- {
- List<Student> stud = new List<Student>
- {
- new Student { RollNo=1, StudFirstName="Ankur", StudLastName="Mistry" },
- new Student { RollNo=2, StudFirstName="Rahul", StudLastName="Lad" }
- };
- ViewData.Model = stud;
- return View();
- }

Ankur MistryPosted Feb 27, 2016, 6:46 AM
thank you all
Santhakumar MunuswamyPosted Feb 23, 2016, 2:24 PM
Thanks for nice article
Rupali ShindePosted Feb 23, 2016, 5:07 AM
some thing new to learn
Vignesh ManiPosted Feb 22, 2016, 5:49 PM
Nice
Shubham KumarPosted Feb 22, 2016, 12:44 AM
nice
Raja TPosted Feb 21, 2016, 11:13 PM
Thanks for sharing
Humayun Kabir MamunPosted Feb 21, 2016, 11:05 PM
Nice...
Sthitaprajnya Debasis NayakPosted Feb 21, 2016, 4:13 PM
Nice Article !!!
Pravin MarathePosted Feb 21, 2016, 1:36 PM
Nice one sir..