1
Reply

DropDownList - Add attributes to items

goce  micevski

goce micevski

Sep 22 2004 5:20 AM
2.7k
Hello, The problem is this: I have a drop down list and i bound it from db with text and value, so every (list item)option will have value and text. I know how to add style attribute, but i have problem assigning id atribute to every listItem in this list. This is because i need additional info except from value field, ie i need to add info to every option from another datatable column. example: Name.DataSource = dsMobileProductNames; Name.DataTextField = "NAME"; Name.DataValueField = "UNIQUEID"; Name.DataBind(); so after this i wan to do something like this foreach(ListItem li in Name.Items) { li.Attributes.Add("id","here some value"); } so at the end in the html it would like this: Thanks in advance

Answers (1)