I have the same drop down list for 30 fields on a view. Is there any way to use the same selectlist in the viewbag for all 30 with the default value or do I have to have 30 separate viewbag items with the same select list and default value?
I add the selectlist to the viewbag in my contoller edit method:
ViewBag.Pulmonary_01 = new SelectList(PulmonaryList(), "Text", "Value", admission.Pulmonary_01);
The fields are Pulmonary_01 through Pulmonary_30. In my view I use:
@Html.DropDownList("Pulmonary_01", String.Empty)
If I use ViewBag.Pulmonary instead of the _01 it doesn't match it on save. Two obstacles are matching a general "Pulmonary" view and to all the fields so they save and the other is having the selected value. I don't see a way to avoid having 30 ViewBags.