Home All Groups Group Topic Archive Search About

Binding an array to a DropDownList

Author
12 Sep 2006 11:16 PM
paul.hester
Hi all,

I'd like to bind an array to a DropDownList and use the array index as
the DataValueField. Is this possible?

Thanks,

Paul

Author
13 Sep 2006 10:31 AM
Savil Francis
Than array you can bind a collection based class which has values as
objects in that collection class

Define a class like
Public Class Student
{
  public string Name;
  public int ID
}

public Class StudentCollection:System.Collection.CollectionBase
{
  public Student this[int i]
  {
      get
      {
          return (Student)this.base.List[i]
      }
      set
      {
         this.base.List[i]=value;
      }
  }
}

And this class could be bound to any controls

Bookmark and Share