<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objSortedList As SortedList
Dim i As Integer
Dim lsItem As String
objSortedList = New SortedList
objSortedList.Add("white", "#FFFFFF")
objSortedList.Add("black", "#000000")
objSortedList.Add("red", "#FF0000")
objSortedList.Add("yellow", "#FFFF00")
objSortedList.Add("green", "#00FF00")
Session("mySession") = objSortedList
Me.lblText.Text = "SortedList Created <a href=AspNetSortedListSession2.aspx>click here</a> to view"
End Sub
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - SortedList</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label id="lblText" runat="server"></asp:Label>
<br />
</form>
</body>
</html>
AspNetSortedListSession2.aspx
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim objSortedList As SortedList
Dim i As Integer
Dim lsItem As String
objSortedList = Ctype(Session("mySession"),SortedList)
For Each lsItem In objSortedList.Keys
Me.lblText.Text = Me.lblText.Text & "Key = " & lsItem & " , Value = " & objSortedList.Item(lsItem) &"<br>"
Next
End Sub
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - SortedList</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label id="lblText" runat="server"></asp:Label>
<br />
</form>
</body>
</html>