Dropdownlist : Add Custom Attributes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • boysenberry
    New Member
    • Jun 2007
    • 18

    #1

    Dropdownlist : Add Custom Attributes

    Hi - please help.

    ASP.NET/C#

    I am trying to add more information into the ListItems of a DropdownList. Unfortunately, I cannot add an object to the Dropdownlist (unlike in Windows Forms), so I am trying to add the extra values as attributes, like this.
    ListItem liName = new ListItem();
    liName.Text = "Peter Pan";
    liName.Value = "100";
    liName.Attribut es.Add("Address ", "Neverland" );

    ddlNames.Items. Add(liName);

    This goes through without error, but I cannot later reference this attribute to find the address for the selected item in the dropdownlist.

    How can I do this?

    Many thanks

    BB
Working...