Step1
We need to put this code in the controller i.e
IndexController
ViewBag.Categories = db.Categories.ToList();
Where db is a object of a database connection and categories is the name of the
table
Step2
We also need to put the code in the cshtml
page i.e IndexCshtml.
@Html.DropDownListFor(model => model.CategoryId, new
SelectList(ViewBag.Categories, "CategoryId", "CategoryName"), "Select a
Category")

Lalit RaghuvanshiPosted Jan 18, 2015, 3:52 AM
After searching lots of blogs and website , i found the clear step by step and easiest solution to bind dropdownlist from sql database on :Dynamically bind Asp.Net MVC Dropdownlist from Sql Server Database using entity frameworkhttp://www.webcodeexpert.com/2015/01/how-to-dynamically-bind-aspnet-mvc.html
Łukasz KordowskiPosted Aug 25, 2014, 6:10 AM
hey thanks. but have one issue. it sends null or 0 instead of chosen index to model. any idea?
pavan kumarPosted Aug 8, 2014, 12:43 AM
Thanku sir i am new to mvc