Example <%@ Page language= "VB"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd XHTML 1.1//en" "Http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
<script runat= "Server" >
Sub Datalist1_itemcommand (ByVal source as Object, ByVal e as System.Web.UI.WebControls.DataListCommandEventArgs)
If e.commandsource.id = "LinkButton1" Then
Datalist1.selectedindex = E.item.itemindex
' ElseIf e.commandsource.id = ' LinkButton2 ' Then
' ElseIf e.commandsource.id = ' LinkButton4 ' Then
' Datalist1.edititemindex = E.item.itemindex
ElseIf e.commandsource.id = "LinkButton3" Then
Datalist1.edititemindex =-1
ElseIf e.commandsource.id = "LinkButton5" Then
Response.Write ("Hello")
End If
Datalist1.databind ()
End Sub
Sub Datalist1_editcommand (ByVal source as Object, ByVal e as System.Web.UI.WebControls.DataListCommandEventArgs)
Datalist1.edititemindex = E.item.itemindex
Datalist1.databind ()
End Sub
Sub Datalist1_cancelcommand (ByVal source as Object, ByVal e as System.Web.UI.WebControls.DataListCommandEventArgs)
Response.Write ("This is Test..................dingding")
Datalist1.selectedindex =-1
Datalist1.databind ()
End Sub
</script>
<title>untitled page</title>
<body>
<form id= "Form1" runat= "Server" >
<div>
<asp:datalist id= "DataList1" runat= "Server" datakeyfield= "ID" datasourceid= "AccessDataSource1" onitemcommand= " Datalist1_itemcommand "oneditcommand=" Datalist1_editcommand "oncancelcommand=" Datalist1_cancelcommand ">
<SelectedItemTemplate>
Id:
<asp:label id= "Label1" runat= "server" text= ' <%# Eval ("ID")%> ' ></asp:Label>
<br/>
Art_title:
<asp:label id= "Label2" runat= "server" text= ' <%# Eval ("Art_title")%> ' ></asp:label><br/>
Ip:
<asp:label id= "Label3" runat= "server" text= ' <%# Eval ("IP")%> ' ></asp:Label>
<asp:linkbutton id= "LinkButton2" runat= "Server" commandname= "Cancel" >return</asp:LinkButton>
<asp:linkbutton id= "LinkButton4" runat= "Server" commandname= "edit" >edit</asp:LinkButton>
<br/>
<br/>
</SelectedItemTemplate>
<ItemTemplate>
Id:
<asp:label id= "Idlabel" runat= "server" text= ' <%# Eval ("ID")%> ' ></asp:Label>
<asp:linkbutton id= "LinkButton1" runat= "Server" >more</asp:LinkButton>
<br/>
<br/>
</ItemTemplate>
<EditItemTemplate>
Id:
<asp:textbox id= "TextBox1" runat= "server" text= ' <%# Eval ("ID")%> ' ></asp:TextBox>
<br/>
Art_title:
<asp:textbox id= "TextBox2" runat= "server" text= ' <%# Eval ("Art_title")%> ' ></asp:TextBox>
<br/>
Ip:
<asp:textbox id= "TextBox3" runat= "server" text= ' <%# Eval ("IP")%> ' ></asp:TextBox>
<BR/><asp:linkbutton id= "LinkButton3" runat= "Server" >CANCER</asp:LinkButton>
<asp:linkbutton id= "LinkButton5" runat= "Server" >SUBMIT</asp:LinkButton>
<br/>
</EditItemTemplate>
</asp:DataList>
<asp:accessdatasource id= "AccessDataSource1" runat= "