C# 编辑现有数据时,IsPostBack属性返回false而不是true

C# 编辑现有数据时,IsPostBack属性返回false而不是true,c#,asp.net,gridview,postback,C#,Asp.net,Gridview,Postback,我有一个带有gridview的页面(实际上是两个,但它们是相同的,并且两个页面中的任何一个都会发生相同的事情) 新行通过链接按钮从footerrow添加到gridview 当使用页面编辑现有数据时,会发生奇怪的事情。当我第一次尝试向gridview添加另一行时,在编辑模式下创建页面(即从表中的现有数据集中添加/删除行),iPostback设置为false,因此gridview重新初始化/重新绑定,我的更改丢失。第二次也是以后我尝试添加行时,它可以很好地识别回发 是什么原因导致回发未被识别为回发

我有一个带有gridview的页面(实际上是两个,但它们是相同的,并且两个页面中的任何一个都会发生相同的事情)

新行通过链接按钮从footerrow添加到gridview

当使用页面编辑现有数据时,会发生奇怪的事情。当我第一次尝试向gridview添加另一行时,在编辑模式下创建页面(即从表中的现有数据集中添加/删除行),iPostback设置为false,因此gridview重新初始化/重新绑定,我的更改丢失。第二次也是以后我尝试添加行时,它可以很好地识别回发

是什么原因导致回发未被识别为回发

我不确定是否值得发布代码,但我将发布我的页面加载,以获取它的价值:

查询字符串: a=n为“新建”(用于创建页面以添加一组新记录) a=e为“编辑”(使用现有数据填充页面,以允许添加/删除行)

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String action = Request.QueryString["a"];
            if (action == "n")
            {
                BindBuyGrid("create");
                BindSellGrid("create");
            }
            else if(action == "e")
            {
                PopulatePage();
            }
        }
    }
更新1

protected void gvwBuyConditions_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "InsertNew")
        {
            AddNewRowToBuyConditionsGrid();
        }
    }
更新2 链接按钮代码。这肯定会触发回发吗

<FooterTemplate>
    <asp:LinkButton
        ID="lnkInsert"
        runat="server"
        CommandName="InsertNew"
        ToolTip="Add New Entry to List" >
        <img src="../Images/Add.ico" height="20" width="20"/></asp:LinkButton>
</FooterTemplate>
更新4 上一页中调用此页的代码。e只是在字符串中配置的。可能是服务器。传输吗

 protected void gvwStrategyList_RowCommand(Object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "UseEditForm")
    {
        //row index
        int index = Convert.ToInt32(e.CommandArgument);

        //retrieve StrategyID  
        int StrategyID = Convert.ToInt32(gvwStrategyList.DataKeys[index].Value);

        Server.Transfer("~/AddStrategy.aspx?a=e&z=" + StrategyID, true);
    }
}

可能是一些全局重定向?我想可能是这种类型的。我只有一个重定向-它用于在保存一组新的网格数据后返回到上一页。因此在这种情况下不会触发。@Saurabh-不这样认为-这是双重回发。我甚至在需要时都没有收到一个。现在开始
 protected void gvwStrategyList_RowCommand(Object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "UseEditForm")
    {
        //row index
        int index = Convert.ToInt32(e.CommandArgument);

        //retrieve StrategyID  
        int StrategyID = Convert.ToInt32(gvwStrategyList.DataKeys[index].Value);

        Server.Transfer("~/AddStrategy.aspx?a=e&z=" + StrategyID, true);
    }
}