public HtmlOption[] GetOptions(string type, string curValue) { if (string.IsNullOrEmpty(curValue)) { return(GetOptions(type)); } IList itemList = this.optionItemDao.FindAll(type); if (null == itemList || itemList.Count == 0) { return(HtmlOption.GetBlankHtmlOption()); } IList optionsList = new ArrayList(); bool isHave = false; for (int i = 0; i < itemList.Count; i++) { OptionItem optionItem = (OptionItem)itemList[i]; if (!isHave && curValue.Equals(optionItem.Code, StringComparison.OrdinalIgnoreCase)) { isHave = true; } optionsList.Add(new HtmlOption(optionItem.Name, optionItem.Code)); } if (!isHave) { optionsList.Add(new HtmlOption(curValue, curValue)); } HtmlOption[] options = new HtmlOption[optionsList.Count]; optionsList.CopyTo(options, 0); return(options); }
public HtmlOption[] GetOptions(string type) { IList itemList = this.optionItemDao.FindAll(type); if (null == itemList || itemList.Count == 0) { return(HtmlOption.GetBlankHtmlOption()); } HtmlOption[] options = new HtmlOption[itemList.Count]; for (int i = 0; i < itemList.Count; i++) { OptionItem optionItem = (OptionItem)itemList[i]; options[i] = new HtmlOption(optionItem.Name, optionItem.Code); } return(options); }
public HtmlOption[] GetTypeOptions() { IList typesList = this.optionItemDao.FindAllType(); if (null == typesList || typesList.Count == 0) { return(HtmlOption.GetBlankHtmlOption()); } HtmlOption[] options = new HtmlOption[typesList.Count]; int index = 0; foreach (object[] typeInfos in typesList) { options[index++] = new HtmlOption(typeInfos[1].ToString(), typeInfos[0].ToString()); } return(options); }