Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
for(int i=1; i<=10; i++)
{
    li.Items.Add(new ListItem("Item" + i));
    if (i%2 == 0)
    {
       li.Items[i-1].Attributes["itemType"] = "Even";
    }
    else
    {
       li.Items[i-1].Attributes["itemType"] = "Odd"";
    }
}


I've added each list item of the li DropDownList an attribute called "itemType". But I 'm not able to get the value assigned to that attribute after I select a different item in li Dropdownlist. I think the attribute "itemType" is also getting deleted when the SelectedItem is changed.

Please help me solving this.
Thank you!
Posted
Comments
Sandeep Mewara 27-Apr-12 6:44am    
Not clear. Add your dropdown html content and then explain what above code is for.
Tanmay Tiwari 27-Apr-12 10:48am    
hii,can you plz show your html content also.then it wll be more convenient for us to give solution.

thanx

1 solution

The items need to be persisted.

see

ASP.NET Color DropDown Control[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900