I need to select the dropdown in html helper. I pass my data in IEnumerable using ViewData please some one help me how to select it with value.
My Code is
When you are building your dropdown list you can select the selected item using Selected property of SelectListItem
myModelCollection = SomeService.GetModels();
var dropdown = myModelCollection.Select(s => new SelectListItem {Value = s.Id, Name = s.Name, Selected = s.Id == YourSelectedValue} ).ToList();