c# - How to set the selected value of multiple MVC dropdownlist in the view without passing unique selectlists for each -
in viewmodel have lot of rows. need user select employee dropdownlist each row. list of employees choose same each row, this:
@foreach(var item in model.rows) { @html.dropdownlistfor(m => item.employeeid, model.employeeselectlist, "-- choose --", new {id = "employee_" + item.id }) ... } and model looks this:
public class theviewmodel { public selectlist employeeselectlist {get;set;} public list<row> rows {get;set;} } do need have selectlist in row class instead able set selected value without using javascript or missing something?
the reason asking question off course amount of redundant data sent client lot.
as pointed out me in comments below, html rendered @ server anyway doesn't matter.
jarvanjiang helped me clarify me can see in conversation under question. thank you!
the answer is: not possible.
its because not matter html rendered @ server anyway. , each row has -tags when sent client. time not redundant data more, screen.
Comments
Post a Comment