NET Tutorial: ASP.net sortedlist objects

Source: Internet
Author: User

NET Tutorial: ASP.net sortedlist objects

The SortedList object features a combination of ArrayList objects and hash table objects.

In the SortedList object
The SortedList object contains the key/value pairs of the item. A sortedlist automatically sorts the alphabetical or numeric order of items in an object.

Item added to SortedList and purchase () method. A sortedlist size can be used for its final size and trimtosize () method.

The following code creates a sortedlist named Mycountries and four elements said:

<script runat= "Server" >
Sub Page_Load
If not Page.IsPostBack then
Dim mycountries=new SortedList
Mycountries. ADD ("N", "Norway")
Mycountries. ADD ("S", "Sweden")
Mycountries. ADD ("F", "France")
Mycountries. ADD ("I", "Italy")
End If
End Sub
</script>
Data binding a SortedList object can automatically generate text and values the following controls: Dynamic: RadioButtonList Dynamic: CheckBoxList Dynamic: Drop-down list dynamic: List box binding data to RadioButtonList control, First, create a RadioButtonList control (without any asp:listitem elements). ASPX page:html>
<body><form runat= "Server" >
<asp:radiobuttonlist id= "RB" runat= "Server"
autopostback= "True"/></form></body>
< ml> then add the script to build the list: <script runat= "Server" >
Sub Page_Load
If not Page.IsPostBack then
Dim mycountries=new SortedList
Mycountries. ADD ("N", "Norway")
Mycountries. ADD ("S", "Sweden")
Mycountries. ADD ("F", "France")
Mycountries. ADD ("I", "Italy")
Rb. Datasource=mycountries RB. Datavaluefield= "Key" RB. Datatextfield= "Value" RB. DataBind ()
End If
End Sub
</script><body><form runat= "Server" >
<asp:radiobuttonlist id= "RB" runat= "Server"
autopostback= "True"/></form></body>
< ml>

Related Article

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.