how are you doing it? if it is in ItemCommand, tryvoid DataGrid_ItemCommand(Object sender, DataGridCommandEventArgs e) 
{
       Button btn = (Button)e.CommandSource;
       TableCell tc = (TableCell)btn.Parent;
       DataGridItem dgi = (DataGridItem)tc.Parent;
       int i = dgi.Cells.GetCellIndex(tc);
}

解决方案 »

  1.   

    <ASP:DataGrid OnCancelCommand="Cancel_Click" OnUpdateCommand="Update_Click" OnDeleteCommand="delete_Click" OnEditCommand="Edit_Click"/>
    Columns>
    <asp:EditCommandColumn EditText="编辑" CancelText="取消" UpdateText="更新" ItemStyle-Wrap="false" />
    </olumns>
    通过使用EditCommandColumn 就可以对该列进行编辑
      

  2.   

    判断CommandSource
     switch(((LinkButton)e.CommandSource).CommandName)
             {            case "Delete":
                   DeleteItem(e);
                   break;            // Add other cases here, if there are multiple ButtonColumns in 
                // the DataGrid control.            default:
                   // Do nothing.
                   break;