假设按钮列是第一列:
this.DataGrid_sale.Items.Cells[0].Attributes.Add("onclick","open_confirm();");

解决方案 »

  1.   

    不行呀!Items没有Cells这个属性,只有Items[i]有Cells的属性
    这句话:this.DataGrid_sale.Items[i].Attributes.Add("onclick","open_confirm();");
    改成
    this.DataGrid_sale.Items[i].Cell[0].Attributes.Add("onclick","open_confirm();");
    依然和原来的一样,点DataGrid任何地方都响应我加的事件
      

  2.   

    if (e.Item.ItemIndex>=0)
    {
    TableCell myTableCell= e.Item.Cells[3];
    LinkButton myDeleteButton=(LinkButton)myTableCell.Controls[0];
    myDeleteButton.Attributes.Add("onclick", "return confirm('您确认删除?');");
    }
      

  3.   

    http://www.csdn.net/Develop/read_article.asp?id=27280