Exemplo n.º 1
0
 /// <summary>
 ///  Binds data from the data source to the control.
 /// </summary>
 /// <param name="dataSource">The System.Collections.IEnumerable list of data returned from a System.Web.UI.WebControls.DataBoundControl.PerformSelect() method call.</param>
 protected override void PerformDataBinding(IEnumerable dataSource)
 {
     base.PerformDataBinding(dataSource);
     if (dataSource != null)
     {
         string dataValueField = this.DataValueField;
         if (!this.AppendDataBoundItems)
         {
             this.Items.Clear();
         }
         ICollection dataCollection = dataSource as ICollection;
         if (dataCollection != null)
         {
             this.Items.Capacity = dataCollection.Count + this.Items.Count;
         }
         foreach (object dataItem in dataSource)
         {
             var item = new DataListItem();
             if (!string.IsNullOrEmpty(dataValueField))
             {
                 item.Value = DataBinder.GetPropertyValue(dataItem, dataValueField, null);
             }
             else
             {
                 item.Value = dataItem.ToString();
             }
             this.Items.Add(item);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Adds a new item to the collection
 /// </summary>
 /// <param name="item">New Item to Add</param>
 public void Add(DataListItem item)
 {
     this.listItems.Add(item);
     if (this.marked)
     {
         item.Dirty = true;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Removes the specified item from collection
        /// </summary>
        /// <param name="item">The item to Remove</param>
        public void Remove(DataListItem item)
        {
            int index = this.IndexOf(item);

            if (index >= 0)
            {
                this.RemoveAt(index);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object" /> is equal to the current <see cref="DotM.Html5.WebControls.DataListItem" />
        /// </summary>
        /// <param name="o">The <see cref="System.Object" /> to compare with the current DataListItem</param>
        /// <returns>true if the specified <see cref="System.Object" /> is equal to the current <see cref="DotM.Html5.WebControls.DataListItem" />; otherwise, false.</returns>
        public override bool Equals(object o)
        {
            DataListItem item = o as DataListItem;

            if (item == null)
            {
                return(false);
            }
            return(this.Value.Equals(item.Value));
        }
Exemplo n.º 5
0
        int IList.Add(object item)
        {
            DataListItem item2 = (DataListItem)item;
            int          num   = this.listItems.Add(item2);

            if (this.marked)
            {
                item2.Dirty = true;
            }
            return(num);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Determines if the collection contains a specified item
 /// </summary>
 /// <param name="item">The item to look for</param>
 /// <returns>True if collection contains the specified item; otherwise false</returns>
 public bool Contains(DataListItem item)
 {
     return(this.listItems.Contains(item));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Inserts an element into the Collection at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index at which value should be inserted.</param>
 /// <param name="item">The value to insert</param>
 public void Insert(int index, DataListItem item)
 {
     this.listItems.Insert(index, item);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Searches for the specified System.Object and returns the zero-based index of the first occurrence within the entire System.Collections.ArrayList.
 /// </summary>
 /// <param name="item">The System.Object to locate in the System.Collections.ArrayList. The value can be null.</param>
 /// <returns>The zero-based index of the first occurrence of value within the entire System.Collections.ArrayList, if found; otherwise, -1.</returns>
 public int IndexOf(DataListItem item)
 {
     return(this.listItems.IndexOf(item));
 }