<%@ Page Language="VB" debug="true" ValidateRequest="false" %>
<script runat="server">
Friend Class clsUser
Private _ID As Integer
Public Property ID() As Integer
Set(ByVal value As Integer)
_ID = value
End Set
Get
Return _ID
End Get
End Property
Public Sub New()
_ID = 0
End Sub
End Class
Private Sub Page_Load(ByVal Sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
BindList()
End If
End Sub
Private Sub BindList()
Dim coll As New Collection
Dim cls As clsUser
Dim i As Integer
For i = 1 To 9
cls = New clsUser
cls.ID = i
coll.Add(cls)
Next
dlist.DataSource = coll
dlist.DataBind()
End Sub
Private Sub dlist_ItemCommand(ByVal source As Object, ByVal e As DataListCommandEventArgs)
Select Case e.CommandName.ToLower
Case "lnkreset"
Dim SelectedID As Integer = CInt(dlist.DataKeys(e.Item.ItemIndex))
Dim lb As LinkButton = CType(e.Item.FindControl("OpenClose"), LinkButton)
If lb.Text = "Close" Then
lb.Text = "Open"
Else
lb.Text = "Close"
End If
Case Else
End Select
End Sub
</script>
<html>
<head>
<title></title>
</head>
<body>
<form id="Form1" runat="server">
<p><asp:Literal runat="server" ID="litX" EnableViewState="false"></asp:Literal></p>
<asp:DataList ID="dlist" runat="server" DataKeyField="ID" Width="192px" Height="80px" OnItemCommand="dlist_ItemCommand">
<ItemTemplate>
<li>
<asp:LinkButton id="OpenClose" runat="server" Text="Close" CommandName="lnkreset"></asp:LinkButton>
</li>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>