Code Snippet posted by:
Maheshvishnu | Posted on: 9/4/2012 | Category:
ASP.NET Codes | Views: 468 | Status:
[Member] |
Points: 40
|
Alert Moderator
VIEW:
Pass viewdata attribute in dropdownlist html designing code
Html.DropDownList("CarsList", new SelectList((IEnumerable)ViewData["CarsList"], "ID", "Name"))
CONTROLLER:
first get required data from database and then pass the resultant data to view from controller using viewdata attribute
public ActionResult GetData()
{
var CarNames = from c in obj.Cars
select c;
ViewData["Carsist"] = CarNames;
return View();
}
mahesh
Found interesting? Add this to: