就是这样的代码,执行就知道了<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="Web0330.WebForm2" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 168px"
runat="server" Width="736px" Height="136px" ShowFooter="True">
<Columns>
<asp:BoundColumn DataField="IntegerValue" HeaderText="IntegerValue"></asp:BoundColumn>
<asp:BoundColumn DataField="StringValue" HeaderText="StringValue"></asp:BoundColumn>
<asp:BoundColumn DataField="CurrencyValue" HeaderText="CurrencyValue"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="选项">
<ItemTemplate>
<asp:Button id="Button1" runat="server" Width="80px" Text="Button" CommandName="butt" CausesValidation="true"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
<asp:ButtonColumn Text="选择" CommandName="Select"></asp:ButtonColumn>
</Columns>
</asp:DataGrid></FONT>
</form>
</body>
</HTML>using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace Web0330
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
// Create sample data for the DataGrid control.
DataTable dt = new DataTable();
DataRow dr;
 
// Define the columns of the table.
dt.Columns.Add(new DataColumn("IntegerValue", typeof(Int32)));
dt.Columns.Add(new DataColumn("StringValue", typeof(string)));
dt.Columns.Add(new DataColumn("CurrencyValue", typeof(double)));
 
// Populate the table with sample values.
for (int i = 0; i < 5; i++) 
{
dr = dt.NewRow();
 
dr[0] = i;
dr[1] = "Item " + i.ToString();
dr[2] = 1.23 * (i + 1);
 
dt.Rows.Add(dr);
}
 
DataView dv = new DataView(dt); DataGrid1.DataSource=dv;
DataGrid1.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);

this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
int sadf = 3;
}
}
}