开发者

Two Html.DropDownListFor for one Model property?

开发者 https://www.devze.com 2023-03-16 14:38 出处:网络
I have two select lists, and I want the selection for both to go to one property in the Model. <li>

I have two select lists, and I want the selection for both to go to one property in the Model.

        <li>
             @Html.DropDownListFor(model => model.Year, (SelectList)fiscalYearsList, "All Years", new { id = "fiscalYearsList", style= "display:none" })
        </li>
        <li>
             @Html.DropDownListFor(model => model.Year, (SelectList)calendarYearsList, "All Years", new { id = "calendarYearsList" })
        </li>

Then with Jquery I am toggling each whenever a radio button is selected. Is this possible to send just the selected item from the visible DropDownListFor to the model? It is开发者_开发技巧 not quite working at the moment. Only the first DropDownListFor actually gets sent to the model.


I ended up adding another property to my View Model and then adding a little extra logic to display the correct DropDownListFor with Javascript. Works fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号