Extended attributes of listitem in dropdownlist

Source: Internet
Author: User

When the extended attribute attributes is added to the listitem, if the page is sent back, the attribute will be lost. I found it online for half a day and said it was a Microsoft Bug. Finally, I came up with a Bt method: binding every time, then set the selected location

Code
String n = DDL. selectedvalue;
DDL. Items. Clear ();
For (INT I = 0; I <10; I ++)
{
Listitem li = new listitem ();
Li. Text = I;
Li. value = I;
Li. attributes ["ID"] = I;
DDL. Items. Add (LI );
}

DDL. selectedindex = DDL. Items. indexof (DDL. Items. findbyvalue (n ));

 

Compared with other solutions, this solution has a poor performance, but is easy to use.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.