Tuesday, February 22, 2011

MVC dropdown databinding

In controller page we need to use this code, here categoryid is VALUEFIELD and category1 is TEXTFIELD then the last parameter is default value to be displayed:

SelectList Category = new SelectList(CE.category,"categoryid","category1", "Select the category");

 
ViewData["Category"] = Category;

No comments:

Post a Comment