我在GridView的footerRow想增加一个新建的按钮。代码如下:LinkButton mybutton = new LinkButton();
mybutton.Text = "新建";
mybutton.Click += new EventHandler(Button1_Click);
GridView1.FooterRow.Cells[0].Controls.Add(mybutton);原来是在GridView的Load事件下增加此代码的,后来我发现一旦运行删除事件,就没有执行此增加新键按钮的方法。我就在GridView的RowDeleted事件中加上此代码,还是不行。我知道是因为在RowDeleted结束后,可能Gridview还没有呈现的原因。我想知道如何做,才能在删除后,也显示出这个新建的按钮,谢谢。

解决方案 »

  1.   

    if you can, try to add the button to your template directly, for example, see<FooterTemplate>
                      <asp:TextBox ID="tbInsert" runat="server" Text="" ></asp:TextBox>
                </FooterTemplate>http://geekswithblogs.net/casualjim/archive/2006/05/04/77151.aspxoradd your above code in Page's Init or Load event handler
      

  2.   

    我发现在删除后,我在Page的Load事件增加控件的按钮,是没有用的。
      

  3.   

    而且GridView中也不能这样写。
    <FooterTemplate>
                      <asp:TextBox ID="tbInsert" runat="server" Text="" ></asp:TextBox>
                </FooterTemplate>说并不骨FooterTemplate这个属性啊。
      

  4.   

    一个简单的方法,在RowDeleted事件中,将GridView的DataBind事件,加载到你增加控件的地方,就可以了。protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
        {
            GridView1.DataBound +=new EventHandler(Page_Load);
        }只要你在Page_Load事件中有增加控件就行了。