Results 1 to 4 of 4

Thread: [2005] Binding listbox to hashtable

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2005
    Location
    New Jersey, USA
    Posts
    119

    [2005] Binding listbox to hashtable

    In an ASP.net application, i was able to create a hashtable, and bind a dropdownlist to it:

    C# Code:
    1. DropDownList1.DataSource = myHashTable;
    2. DropDownList1.DataTextField = "Key";
    3. DropDownList1.DataValueField = "Value";
    4. DropDownList1.DataBind();

    this worked successfully.

    When I tried it in a winforms app, binding a listbox to a hashtable:

    C# Code:
    1. ListBox1.DataSource = myHashTable;
    2. ListBox1.DisplayMember = "Key";
    3. ListBox1.ValueMember = "Value";

    I got an error saying that complex databinding requires an implementation of IList or IListSource as a datasource.

    What am i doing wrong?
    Last edited by penagate; Jul 18th, 2007 at 11:59 AM. Reason: added code tags
    Dim person As New Person
    Person.GrowUp(ByVal school as string, ByVal gang as string, Byval family as string)
    Person.Work
    Dim A as Integer
    For A = 1 to 10
    Person.Marry()
    Person.Divorce()
    Next
    Person.GiveUp()
    Person.Die()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width