I have the following inside my asp.net mvc web application :-
<div class="SmallDropDown2 b" >
@ViewBag.pagesize // to test the value Show
@Html.DropDownList("pagedsizeoptions", new SelectList(ViewBag.PagedSizeOptions, "Value", "Text", ViewBag.pagesize ), new { @id= "pagedsizeoptions",@class="SmallDropDown3"}) per page.
<img src="~/Content/sortloading.gif" class="loadingimage" id="progressSort3" /></div>
currently the DropdownList is ignoring the default value which should equal to ViewBag.pagesize. and even if i manually specify the defualt value , it will also be ignored, as follow !!!:-
@Html.DropDownList("pagedsizeoptions", new SelectList(ViewBag.PagedSizeOptions, "Value", "Text", 100 ), new { @id= "pagedsizeoptions",@class="SmallDropDown3"})
Can anyone advice why i am unable to specify a default value for the Html.DropdownList ? Thanks
EDIT here is how i am building the SelectList :-
public PageOptions()
{
int size = Int32.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["TechPageSize"]);
FilterOptions = new SelectList(
new List<SelectListItem> {
new SelectListItem { Text=size.ToString(), Value = size.ToString()},
new SelectListItem { Text="50", Value = "50"},
new SelectListItem { Text="100", Value = "100"},
new SelectListItem { Text="200", Value = "200"},
new SelectListItem { Text="500", Value = "500"}
}, "Value", "Text");
}
public SelectList FilterOptions { get; set; }