日期:2014-05-17 浏览次数:20519 次
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField HeaderText="操作">
<ItemTemplate>
<table>
<td align="center" style="width=78px">
<asp:Button ID="Edit" runat="server" Text="编辑" Visible="true" OnClick="Edit_Click"/>
<asp:Button ID="Cancel" runat="server" Text="取消" Visible="false" OnClick="Cancel_Click" />
</td>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_LoadComplete(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add("11");
dt.Rows.Add("1");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void Edit_Click(object sender, EventArgs e)
{
Control c =((Button)sender).Parent.FindControl("Cancel");
if (c != null)
{
c.Visible = true;
&nbs