开发者

Two Html.DropDownListFor for one Model property?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜