How to insert and retrieve two models in one view on MVC Asp.net? Step by step

Опубликовано: 26 Февраль 2026
на канале: On Work
1,709
27

lets' see ..
how can i insert into database and retrieve ..
Hi, In this tutorial you will look how to insert the data into database. using MVC. you can follow the below steps for this tutorial

Step 1 : Select MVC web application
Step 2 : Select Empty template with MVC view Engine.
Step 3 : Create the Database,Table for Which you are going to insert
Step 4 : Right Click on model folder add a class file to it.
Step 5 : Give the name to the class file created in Model folder.
Step 6 : Start writing code to model.
Create Property class for the details to insert.
Create function for inserting details( DB Layer Coding )
Step 7 : Right Click on Controller folder and create new Controller.
Step 8: Give name to the controller followed by the text 'Controller'
Step 9 : Write coding to your Controller
Step 10 : Create view by placing your cursor near your ActionResult name as below.
Step 11 : Keep View name as it looks. check strongly typed view select your model.
Step 12 : Your View Firstly looks like below.
Step 13 : Add the below code to the view.
Your Coding part is completed. Now Run your Application