title: GridView paging in UpdatePanel
body: <p>I have an UpdatePanel and a GridView within it. I have a problem with paging: when I press Next button, grdUsers_PageIndexChanging() is not called, so the page stays 1, and if previously I changed selection in ddlPageSize, now it goes back to the initial selection.
  Also, if I am on the first page, the Previous button is not disabled, and pressing it causes Out Of Range error.
  What am I doing wrong?
  Thanks.</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="upnlUsers" runat="server" ChildrenAsTriggers="true" UpdateMode="Always" &gt;
      &lt;ContentTemplate&gt;
  
          &lt;div style="height:400px; width:1500px; overflow:auto;"&gt;
  
          &lt;asp:GridView ID="grdUsers" runat="server" AllowPaging="True" ShowHeader="false" ShowFooter="true" 
              AutoGenerateColumns="false" CssClass="largegridview largegridview_td" 
              Width="1480px" Height="100%" PageSize="100" DataKeyNames="ID" EnableSortingAndPagingCallbacks="false" 
                  onpageindexchanging="grdUsers_PageIndexChanging" 
                  onrowdatabound="grdUsers_RowDataBound"&gt;
                  &lt;AlternatingRowStyle CssClass="alternatingrowstyle" /&gt;
  
                  &lt;Columns&gt;
                       &lt;asp:TemplateField HeaderText="User Name" SortExpression="Name"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblName" runat="server" Text='&lt;%# Eval("Name") %&gt;'&gt;&lt;/asp:Label&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField HeaderText="Last Name" SortExpression="LastName"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblLastName" runat="server" Text='&lt;%# Eval("LastName") %&gt;'&gt;&lt;/asp:Label&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;                        
                      &lt;asp:TemplateField HeaderText="First Name" SortExpression="FirstName"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblFirstName" runat="server" Text='&lt;%# Eval("FirstName") %&gt;'&gt;&lt;/asp:Label&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField HeaderText="Email" SortExpression="Email"&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblEmail" runat="server" Text='&lt;%# Eval("Email") %&gt;'&gt;&lt;/asp:Label&gt;
                          &lt;/ItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;                        
  
                  &lt;/Columns&gt;
  
                  &lt;PagerStyle CssClass="pagerstyle" /&gt;
                  &lt;PagerTemplate&gt;
                      &lt;asp:Label ID="Label1" runat="server" Text="Show rows:" /&gt;
                      &lt;asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true" 
                          OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged"&gt;
                          &lt;asp:ListItem Value="20" /&gt;
                          &lt;asp:ListItem Value="50" /&gt;
                          &lt;asp:ListItem Value="100" /&gt;
                      &lt;/asp:DropDownList&gt;
                      &amp;nbsp;
                      Page 
                      &lt;asp:TextBox ID="txtGoToPage" runat="server" AutoPostBack="true" 
                          OnTextChanged="GoToPage_TextChanged" CssClass="gotopage" /&gt;
                      of
                      &lt;asp:Label ID="lblTotalNumberOfPages" runat="server" /&gt;
                      &amp;nbsp;
                      &lt;asp:Button ID="btnPrev" runat="server" CommandName="Page" 
                          ToolTip="Previous Page" CommandArgument="Prev" CssClass="previous" /&gt;
                      &lt;asp:Button ID="btnNext" runat="server" CommandName="Page" ToolTip="Next Page" 
                          CommandArgument="Next" CssClass="next" /&gt;                  
                  &lt;/PagerTemplate&gt;                      
              &lt;/asp:GridView&gt;
          &lt;/div&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>