1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using Bowin.Web.Controls.Mvc;
- namespace EMIS.Web.Controls
- {
- public static class NumberRangeDropdownListExtensions
- {
- public static MvcHtmlString NumberRangeDropdownList(this HtmlHelper htmlHelper,
- int minValue, int maxValue,
- DropdownListOptions dropdownListOptions = null,
- System.Collections.Generic.IDictionary<string, string> htmlAttributes = null)
- {
- if (dropdownListOptions == null)
- dropdownListOptions = new DropdownListOptions();
- List<int> valueList = new List<int>();
- for (int i = minValue; i <= maxValue; i ++)
- {
- valueList.Add(i);
- }
- dropdownListOptions.ItemList = valueList.Select(x => new DropdownListItem { Text = x.ToString(), Value = x.ToString() }).ToList();
- if (dropdownListOptions.SelectedValue == null)
- {
- dropdownListOptions.SelectedValue = DropdownList.PLEASE_SELECT.ToString();
- }
- return htmlHelper.DropdownList(dropdownListOptions, htmlAttributes);
- }
- }
- }
|