Adf.Web.Binding.ListBoxBinder.Bind C# (CSharp) Method

Bind() public method

Populates the specified System.Web.UI.WebControls.DropDownList with the specified list using the specified parameters.
public Bind ( object control, IEnumerable values ) : void
control object The /// to bind to.
values IEnumerable The list to bind.
return void
        public virtual void Bind(object control, IEnumerable values, params object[] p)
        {
            if (values == null) return;

            var listBox = control as ListBox;
            if (listBox == null) return;

            listBox.Items.Clear();

            foreach (var value in values)
            {
                var text = (value is Enum) ? (value as Enum).GetDescription() : value.ToString();

                //ListItem listItem = new ListItem(value.ToString());
                var listItem = new ListItem(text);

                if (p != null && p.Length > 0)
                {
                    listItem.Selected = text == p[0] as string;
                }

                listBox.Items.Add(listItem);
            }
        }

Same methods

ListBoxBinder::Bind ( object control, object values ) : void
ListBoxBinder::Bind ( object control, object value, PropertyInfo pi ) : void
ListBoxBinder