In this article we will learn how to bind GridView with database in MVC5.
In this tutorial, I’ll show you how to bind GridView using MVC5 C# using Razor. In the previous tutorial I haven’t used any database, but here we will use and then we manually feed some data into our table and bind that data to GridView. So it’s a kind of Binding GridView with database. Step 1
Open Visual Studio 2010, Go to the New Project - Visual C#, Web, then ASP.NET MVC Web Application and click OK. Step 2 After Clicking OK, New ASP.NET MVC5 Project window will open and there you have to choose MVC and press OK. Step 3 After Clicking OK, you will see something like the following image in your Solution Explorer. You need to look out for Model, Controller and View folders that are the main files in MVC, others are too but these are main files. DATABASE CHAMBER: Step 4 Right Click on your Project - Add New Item, then SQL Server Database and Add it. Go to your Database that resides in Server Explorer - [Database.mdf], We will create a table - tbl_data, Go to the database.mdf, Table and Add New table. Design your table like the following: Web.Config File:
Hands on with ASP.Net MVC - Covering MVC 6