0

I have a webgrid and inside it each item has different selectList which consist of model. I want to display name of that model. How can I do that

grid.Column(header: "AvailableDevices", format: @item => Html.DropDownList("value", (IEnumerable<SelectListItem>)item.AvailableDevices)),

List<XXModel> myList = new List<XXModel>();
item.AvailableDevices = new SelectList(myList );

and XX model has property of Name, Age etc. And I want to display name or Age in my dropdown List

albatross
  • 455
  • 2
  • 8
  • 27

1 Answers1

1

you can use this constructor of SelectList:

item.AvailableDevices = new SelectList(myList,"Id","Name" );

See all Available Contructors of SelectList

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160