1. Hide the label and obtain its value to obtain the ID number.
<Itemtemplate>
<Table id = "Table1" cellspacing = "1" cellpadding = "1" width = "300" border = "1">
<Tr>
<TD>
<Asp: linkbutton id = "linkbutton1" runat = "server" commandname = "select" commandargument = '<% # databinder. eval (container. dataitem, "customerid") %> '>
<% # Databinder. eval (container. dataitem, "companyName") %>
</ASP: linkbutton> </TD>
<TD>
<Asp: Label id = "label1" runat = "server">
<% # Databinder. eval (container. dataitem, "customerid") %>
</ASP: Label> </TD>
</Tr>
</Table>
</Itemtemplate>
-- Get the value
Protected void customerslist_itemcommand (Object sender, datalistcommandeventargs E)
{
// Get the name of datalist
String cmd = (linkbutton) E. commandsource). commandname;
If (cmd = "select ")
(Datalist) sender). selectedindex = E. Item. itemindex;
// Re-display data when selecting a new index
Bindlist ();
// Retain customerid
Viewstate [_ customerid] = (Label) E. Item. findcontrol ("customerid"). text;
}
-- Or, I do not understand the difference between the two, maybe microsot is just to reflect different skills
Private void customerlist_itemcommand (Object source, system. Web. UI. webcontrols. datalistcommandeventargs E)
{
String _ customerid;
_ Customerid = (string) E. commandargument;
Label2.text = _ customerid;
}