public static ASPxListBox ApplyDataSource(this ASPxListBox source, IEnumerable dataSource) { source.DataSource = dataSource; source.DataBindItems(); return(source); }
public void InstantiateIn(Control container) { ASPxListBox listBox = new ASPxListBox() { ID = Settings.ListBoxName }; container.Controls.Add(listBox); listBox.ClientInstanceName = Settings.ListBoxName; listBox.Border.BorderWidth = 0; listBox.BorderBottom.BorderWidth = 1; listBox.BorderBottom.BorderColor = Color.FromArgb(0xDCDCDC); listBox.Width = Unit.Percentage(100); listBox.SelectionMode = ListEditSelectionMode.CheckColumn; listBox.ClientSideEvents.SelectedIndexChanged = String.Format("function(s, e){{ OnListBoxSelectionChanged(s, e, {0}); }}", Settings.CheckComboBoxName); if (Settings.DataSource == null) { listBox.Items.AddRange(Settings.Items); listBox.Items.Insert(0, new ListEditItem("(Select all)")); } else { listBox.TextField = Settings.TextField; listBox.ValueField = Settings.TextField; listBox.ValueType = typeof(string); listBox.DataSource = Settings.DataSource; listBox.DataBound += new EventHandler(listBox_DataBound); listBox.DataBindItems(); } container.Controls.Add(new LiteralControl("<div style=\"padding: 6px; height: 24px;\">")); ASPxButton button = new ASPxButton() { ID = Settings.CloseButtonName }; container.Controls.Add(button); button.ClientInstanceName = Settings.CloseButtonName; button.Text = "Close"; button.Style.Add("float", "right"); button.Style.Add("padding", "0px 2px"); button.ClientSideEvents.Click = String.Format("function(s, e){{ {0}.HideDropDown(); }}", Settings.CheckComboBoxName); button.Height = 26; container.Controls.Add(new LiteralControl("</div>")); }
/// <summary> /// Binds the DataTable to Listbox with given value and text fields /// </summary> /// <param name="lstBox">Name of the Listbox to process</param> /// <param name="dt">DataTable to Bind</param> /// <param name="strValue">Value field name as string</param> /// <param name="strText">Text fiels name as string</param> public static void BindListBox(ASPxListBox lstBox, DataTable dt, string strValue, string strText) { //clsDataFunctionsBAL objFunctions = null; try { if (DataTableHasRows(dt)) { lstBox.DataSource = dt; lstBox.ValueField = strValue; lstBox.TextField = strText; lstBox.DataBindItems(); } } catch (Exception ex) { //objFunctions = new clsDataFunctionsBAL(); //objFunctions.SaveErrorLog(ex.Message, m_strModule, MethodBase.GetCurrentMethod().Name); } finally { //objFunctions = null; } }