In this tutorial, I’ll show you how to bind Dropdownlist in MVC C# using Razor.  Here I had take one database and feeded some dummy data. We will also see how that  data comes to our dropdownlist.
 
 INITIAL CHAMBER:
 
 Step 1
 
 Open Visual Studio 2010, Go to the New Project, Visual C#, Web, then ASP.NET MVC3 Web Application. After that click OK.
 
![]()
 
 Step 2
 
 After clicking OK, New ASP.NET MVC3 Project window will open. There choose - Internet Application and in View Engine Dropdown, choose Razor.
 
![]()
 
 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, SQL Server Database and Add  it. Go to your Database residing in Server Explorer - [Database.mdf]. We will  create a table - tbl_Data. After that go to the database.mdf - Table and Add New  table, design your table like this:
 
![]()
 
 In Model
 
 Step 5
 
 Right Click on Models - Add New Item, then Add - ADO.NET Entity Data  Model. After that Name it as Student Model.edmx and ADD it.
 
![]()
 
 Entity Data Model Wizard
 
![]()
 
![]()
 
![]()
 
 After all this you will see your connection string is built in web.config file.  See the following image:
 
![]()
 
 StudentModel.edmx:
 
![]()
In Controller
 
 Step 5
 
 Open Controller, Inside there HomeController.cs files is there. Open that and write code like this. Don’t forget to add namespace of model.
- using System;  
- using System.Collections.Generic;  
- using System.Linq;  
- using System.Web;  
- using System.Web.Mvc;  
- using System.Data.Entity;  
- using MvcApplication6.Models; 
 
- namespace MvcApplication6.Controllers  
- {  
-     public class HomeController : Controller  
-     {  
-         public ActionResult Index()  
-         {  
-   
-             StudentDBContext db = new StudentDBContext();  
-             ViewBag.name = new SelectList(db.tbl_data, "id", "name");  
-   
-   
-             return View();  
-         }  
-   
-         public ActionResult About()  
-         {  
-             return View();  
-         }  
-     }  
- }  
 Open View Folder, Inside that Home folder is there. Open the Index.cshtml file  and write code like this.  
Index.cshtml- @{  
- ViewBag.Title = "Home Page";  
- }  
-   
-   
- <h2>Bind DropdownList in MVC</h2>  
- <p>  
- In this tutorial we will see how to bind Dropdownlist in MVC C# using Razor.  
- </p>  
-   
-   
- @Html.DropDownList("name","--Select Name--")  
![]() 
  Hope you liked it. Thank you so much for reading. Have a good day.