public static MvcHtmlString WHTMonthYearComboBox(this HtmlHelper helper, string id, object attribute = null, bool include_idx0 = true, string firstElement = null) { List <SelectListItem> MonthYearList = new List <SelectListItem>(); try { IIncomeHandler iincomeHandler = ServiceContainer.GetService <IIncomeHandler>() as IIncomeHandler; var yearmonth = iincomeHandler.GetWHTYearMonth(); var thismonth = DateTime.Today.AddDays(1 - DateTime.Today.Day); if (yearmonth.MINYEARMONTH == null) { yearmonth.MINYEARMONTH = thismonth; } if (yearmonth.MAXYEARMONTH == null) { yearmonth.MAXYEARMONTH = thismonth; } for (DateTime dt = yearmonth.MAXYEARMONTH.Value; dt >= yearmonth.MINYEARMONTH; dt = dt.AddMonths(-1)) { MonthYearList.Add(new SelectListItem() { Selected = (dt == thismonth), Text = ToMonthName(dt) + "-" + dt.Year.ToString(), Value = dt.ToShortDateString() }); } ; } catch { } return(CommonUtil.CommonComboBox <SelectListItem>(id, MonthYearList, "Text", "Value", attribute, false)); }