title: gridview commandargument on buttonfield pagination used
body: <p>I am using c#.net</p>
  
  <p>I have a gridview which needs to contain a 'Use' button (appointmentId set as the commandargument).</p>
  
  <p>Source Code</p>
  
  <pre><code>&lt;asp:GridView ID="resultsReturned" runat="server" AllowPaging="True"  
      AutoGenerateColumns="False"
      EnableSortingAndPagingCallbacks="True" 
      OnPageIndexChanged="resultsReturned_PageIndexChanged" 
      onrowcommand="resultsReturned_RowCommand"&gt;
      &lt;Columns&gt;    
        &lt;asp:BoundField DataField="UserAppointmentId" HeaderText="App ID" /&gt;
        &lt;asp:BoundField DataField="UserBookingName" HeaderText="Booking Name" /&gt;
        &lt;asp:TemplateField&gt;
          &lt;ItemTemplate&gt;                
            &lt;asp:Button runat="server" 
              ID="UseButton"
              Text="Use"
              CommandName="Use"
              CommandArgument="UserAppointmentId" /&gt;
          &lt;/ItemTemplate&gt;
        &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
    &lt;/asp:GridView&gt;  
  </code></pre>
  
  <p>Code-Behind</p>
  
  <pre><code>protected void resultsReturned_RowCommand(object sender, GridViewCommandEventArgs e)
  {
      if (e.CommandName == "Use")
      {
          correctAppointmentID.Value = (e.CommandArgument.ToString());
      }
  }
  </code></pre>
  
  <p>This is used for the pagination:</p>
  
  <pre><code>private void BindAppointments()
  {
      var results = appointmentRepos.GetBookingIdBySearchCriteria(catgoryid, resultsReturned.PageIndex * resultsReturned.PageSize, -1);
  
      resultsReturned.DataSource = results;            
      resultsReturned.DataBind();
  }
  </code></pre>
  
  <p>I am binding the appointments to the gridview within the PageLoad/search_Click </p>
  
  <p>This is the error I am receiving:</p>
  
  <blockquote>
    <p>Callbacks are not supported on TemplateField because some controls cannot update properly in a callback.  Turn callbacks off on 'resultsReturned'.</p>
  </blockquote>