ListItems attributes in a DropDownList are lost on postback?
问题 A coworker showed me this: He has a DropDownList and a button on a web page. Here's the code behind: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ListItem item = new ListItem("1"); item.Attributes.Add("title", "A"); ListItem item2 = new ListItem("2"); item2.Attributes.Add("title", "B"); DropDownList1.Items.AddRange(new[] {item, item2}); string s = DropDownList1.Items[0].Attributes["title"]; } } protected void Button1_Click(object sender, EventArgs e) {