I have an MVC3 application with Razor, and I created a View inside which a Partial View is displayed. Here is the main view:
@{Html.RenderPartial("_SearchFilters", Model.SearchFilters);}
@* Other HTML elements *@
Inside _SearchFilters Partial View I have the following DropDownLists inside the Form element:
Choose Year
@Html.DropDownListFor(m => m.Year, new SelectList(Model.YearsList, "Value", "Text"), DateTime.Now.Year)
Choose Month
@Html.DropDownListFor(m => m.Month, new SelectList(Model.MonthsList, "Value", "Text"), Model.Month.ToString(), new { @disabled = "disabled" })
<input type="submit" value="Display" />
I would like that after Send two DropDownLists retain their status, namely the value selected by the user when the View is reloaded with filtered data.
Is there any way to do this without using AJAX?
UPDATE
ViewModel is as follows:
public class TableSearchFiltersViewModel
{
public bool YTM { get; set; }
public int? Month { get; set; }
public int? Year { get; set; }
public IEnumerable<SelectListItem> YearsList
{
get
{
return Enumerable.Range(2011, (DateTime.Now.Year - 2011 + 4)).Select(m => new SelectListItem
{
Value = m.ToString(),
Text = m.ToString(),
}).OrderBy(m => m.Value);
}
}
public IEnumerable<SelectListItem> MonthsList
{
get
{
return Enumerable.Empty<SelectListItem>();
}
}
}
thank
Francesco