public override void UserControlLoad() { if (this.ownerPage == null) { throw new UMSException("Current Page is null or is not inheritor of BasicPage."); } list = LoadList(); if (!string.IsNullOrEmpty(this.WhereKeyValueIntCodesEQ)) { list = ReduceListBySelectedValues(list, this.WhereKeyValueIntCodesEQ, true); } if (!string.IsNullOrEmpty(this.WhereKeyValueIntCodesNotEQ)) { list = ReduceListBySelectedValues(list, this.WhereKeyValueIntCodesNotEQ, false); } this.DropDownList.DataSource = list; this.DropDownList.DataBind(); if (this.SetItemTextAsTooltip) { foreach (ListItem item in this.DropDownList.Items) { item.Attributes.Add("title", item.Text); } this.DropDownList.Attributes.Add("onmouseover", "this.title=this.options[this.selectedIndex].title"); } if (!string.IsNullOrEmpty(DefaultValueByName)) { var defaultValue = list.FirstOrDefault(s => s.Name == DefaultValueByName); if (defaultValue != null) { if (string.IsNullOrEmpty(this.KeyValueDataValueField)) { this.DropDownList.SelectedValue = defaultValue.idKeyValue.ToString(); } else { this.DropDownList.SelectedValue = defaultValue.GetType().GetProperty(this.KeyValueDataValueField).GetValue(defaultValue, null).ToString(); } } } if (!string.IsNullOrEmpty(this.KeyValueDefaultColumn) && !string.IsNullOrEmpty(this.KeyValueDefault)) { var defaultValue = list.AsQueryable <KeyValue>().Where(BaseHelper.BuildPredicate <KeyValue>(this.KeyValueDefaultColumn, this.KeyValueDefault)).FirstOrDefault(); if (defaultValue != null) { if (string.IsNullOrEmpty(this.KeyValueDataValueField)) { this.DropDownList.SelectedValue = defaultValue.idKeyValue.ToString(); } else { this.DropDownList.SelectedValue = defaultValue.GetType().GetProperty(this.KeyValueDataValueField).GetValue(defaultValue, null).ToString(); } } } }