MVC3 Drop Down List Control does not keep State, Why?

前端 未结 2 1334
臣服心动
臣服心动 2021-01-24 01:56

I have a drop down list control on a partial view and after posting the form the state of the drop down list control is not maintained

Here is the partial view cshtml co

2条回答
  •  爱一瞬间的悲伤
    2021-01-24 02:49

    The following code creates the view model for your next partial view:

    TestCriteriaConsolidated combined = new TestCriteriaConsolidated();
    combined.testCriteriaResults = test;
    

    You need to set the year on this model:

    combined.testCriteria.Year = Request.Form["testCriteria.Year"];
    

提交回复
热议问题