title: IsPostBack property returns false instead of true when editing existing data
body: <p>I have a page with a gridview (actually two, but they are identical and the same thing happens with either). </p>
  
  <p>New rows are added to the gridview from the footerrow via a link button.  </p>
  
  <p>When using the page to edit existing data, a strange thing happens.  When I create the page in edit mode (i.e. to add/remove rows from an existing set of data in the table) the first time I try to add another row to the gridview, the IsPostBack is set to false and thus the gridviews re-initialise / rebind and my change is lost.  The second and further time that I try to add rows, it works fine as the PostBack is recognised.</p>
  
  <p>What could be causing the PostBack not to be recognised as one?  </p>
  
  <p>I'm not sure it's worth posting code but I will post my Page_Load for what it is worth:</p>
  
  <p>querystring: 
  a=n is "new" (for creating a page to add a new set of records)
  a=e is "edit" (populate page with existing data to allow for adding / removing rows.</p>
  
  <pre><code>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();
              }
          }
      }
  </code></pre>
  
  <p><strong>Update 1</strong></p>
  
  <pre><code>protected void gvwBuyConditions_RowCommand(object sender, GridViewCommandEventArgs e)
      {
          if (e.CommandName == "InsertNew")
          {
              AddNewRowToBuyConditionsGrid();
          }
      }
  </code></pre>
  
  <p><strong>Update 2</strong>
  The link button code.  Surely this should trigger a postback?</p>
  
  <pre><code>&lt;FooterTemplate&gt;
      &lt;asp:LinkButton
          ID="lnkInsert"
          runat="server"
          CommandName="InsertNew"
          ToolTip="Add New Entry to List" &gt;
          &lt;img src="../Images/Add.ico" height="20" width="20"/&gt;&lt;/asp:LinkButton&gt;
  &lt;/FooterTemplate&gt;
  </code></pre>
  
  <p><strong>Update 3</strong>
  The AddNewRowToBuyConditionsGrid code:</p>
  
  <pre><code> private void AddNewRowToBuyConditionsGrid()
      {
          if (ViewState["BuyConditions"] != null)
          {
              DataTable dtCurrentTable = (DataTable)ViewState["BuyConditions"];
              DataRow drCurrentRow;
  
              GridViewRow row = gvwBuyConditions.FooterRow;
              DropDownList ddlSelectedCondition = row.FindControl("ddlConditionNew") as DropDownList;
  
              try
              {
                  if (ddlSelectedCondition.Text != "Select a Buy Condition")
                  {
                      drCurrentRow = dtCurrentTable.NewRow();
                      drCurrentRow["ConditionName"] = ddlSelectedCondition.SelectedItem.Text;
                      drCurrentRow["ConditionID"] = Convert.ToInt32(ddlSelectedCondition.SelectedItem.Value);
                      dtCurrentTable.Rows.Add(drCurrentRow);
                      drCurrentRow = null;
                  }
                  // take out the dummy "Select a Condition"
                  DataRow drtodie = dtCurrentTable.Rows.Find(-1);
                  if (drtodie != null)
                  {
                      dtCurrentTable.Rows.Find(-1).Delete();
                  }
  
                  //Store the current data to ViewState
                  ViewState["BuyConditions"] = dtCurrentTable;
  
                  //Rebind the Grid with the current data
                  gvwBuyConditions.DataSource = dtCurrentTable;
                  gvwBuyConditions.DataBind();
  
              }
              catch (Exception)
              {
  
                  if (ddlSelectedCondition.SelectedItem.Value == String.Empty)
                  {
                      lblBuyMessage.Text = "Please select a Buy Condition.";
                  }
                  else
                  {
                      lblBuyMessage.Text = "That condition already exists in the list. Please select another condition.";
                  }
              }
          }
          else
          {
              Response.Write("ViewState is null");
          }
      }
  </code></pre>
  
  <p><strong>Update 4</strong>
  Code on previous page that calls this page.  e is just configured in string.  Is it maybe the Server.Transfer?</p>
  
  <pre><code> 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&amp;z=" + StrategyID, true);
      }
  }
  </code></pre>