how do i attach a generic list to dropdown

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    #1

    how do i attach a generic list to dropdown

    hi,

    i have a generic list which has a collection of data
    Code:
       List<Keys> olistkeys=Keys.GetKeysByEmailId(txtEmail.Text);
                 ddlKeys.DataSource = olistkeys;
                 ddlKeys.DataBind();
    But when i bind in dropdownlist, i cant bind it. I mean it means the whole list, whereas i want only the value from the list to be displayed.

    How do i do that

    regards
    cmrhema
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    I mean it means the whole list, whereas i want only the value from the list
    Huh? It means the list, but I only want the value from the list...
    Isn't that like saying "It means the apple, but I only want the apple" ?

    Comment

    • cmrhema
      Contributor
      • Jan 2007
      • 375

      #3
      got it i meant this way
      Code:
      List<Keys> olistkeys=Keys.GetKeysByEmailId(txtEmail.Text);
                   ddlKeys.DataSource = olistkeys;
                   ddlKeys.DataTextField = "KeyValue";
                   ddlKeys.DataBind();

      Comment

      Working...