設置按钮的commandname="test"﹐然后在private void DataList1_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
  if (e.commandname=="test"﹐)
{
   do what you want
}

解决方案 »

  1.   

    在itemdatabinding事件中取label.text加到按钮的attributes中,然后再取attributes
      

  2.   

    在HTML中设置<asp:linkbutton Text="提取"  CommandName="edit" ForeColor="blue" runat="server" ID="Linkbutton2" />在.cs文件中对DataGrid添加EditCommand事件private void rcDataGrid_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
    {
    Label lbl=e.Item.FindControl(Label);
                               string str=lbl.Text.ToString();
    Response.Write("<script language='javascript'>alert('"+str+"')</script>"); }
      

  3.   

    Hero4444(阿神)  
    你的我试了,不行啊zhq3k(zhq3k) 
    没太明白你的意思,能给段代码吗?
      

  4.   

    ((label)e.Item.FindControl("label1")).Attributes["onclick"] = "javscript:alert('aaa');";
      

  5.   

    晕~~~原因查明是因为它!EnableViewState="False"散分了...