MVC 3 and Stored Procedure – part 2

In the first part, I was introduced you how to get the list student and show it on browser.

In this part, I will show you how to Insert the student into database.

III. Insert Student

1. Add View Create

Go to Folder Controllers => HomeController.cs


We choose Scaffold template : Create and Model class: StudentDTO => It will automatically create the form contain all fields of StudentDTO into the Label and TextBox
Now we run and take a look the result.

The ClassName is a textbox but I appreciate the dropdownlist contain the name and value.
2. Get List Class and Show it in the DropDownList

2.1/ Stored Procedure


2.2/ Retrieve the result from Stored Procedure – ClassDAO


2.3/ Declare the variable to store the result from ClassDAO – HomeController.cs


2.4/ Edit the View => Create.cshtml


2.5/ Run


3. Insert the student

3.1/ Stored Procedure


3.2/ Retrieve the result from Stored Procedure – StudentDAO


3.3/ Call the method InsertStudent from StudentDAO – HomeController.cs


3.4/ Run

3 thoughts on “MVC 3 and Stored Procedure – part 2

Leave a comment