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
you can use this constructor of SelectList
:
item.AvailableDevices = new SelectList(myList,"Id","Name" );