在模板列中放linkbutton控件
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%# Eval("id") %>' OnClientClick="return confirm('确定要删除吗!')"
οnclick="lbDelete_Click">删除</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
protected void lbDelete_Click(object sender, EventArgs e)
{
string id= ((LinkButton)sender).CommandArgument;//获取id
}