title: Enable paging in listview when the listview is disabled. ASP.NET C#
body: <p>I have a button (Bearbeitung_Click) to disable/enable my listview which has batch inline editing. This is so that it is not always editable. I want the DataPager in the LayoutTemplate to be constantly enabled so that even when editing is disabled the user can still browse through the pages.</p>
  
  <p>My .aspx code for the template containing the datapager is:</p>
  
  <pre><code> &lt;LayoutTemplate&gt;
              &lt;table runat="server"&gt;
                  &lt;tr runat="server"&gt;
                      &lt;td runat="server"&gt;
                          &lt;table ID="itemPlaceholderContainer" runat="server" border="1" 
                              style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;
                              &lt;tr runat="server" style="background-color: #E0FFFF;color: #333333; font-size:smaller;"&gt;
                                  &lt;th runat="server"&gt;
                                      &lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                                  &lt;th runat="server"&gt;
                                      Example&lt;/th&gt;
                              &lt;/tr&gt;
                              &lt;tr ID="itemPlaceholder" runat="server"&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr runat="server"&gt;
                      &lt;td runat="server" 
                          style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF"&gt;
                          &lt;asp:DataPager ID="DataPager1" runat="server" Enabled="true"&gt;
                              &lt;Fields&gt;
                                  &lt;asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                      ShowNextPageButton="False" ShowPreviousPageButton="False" /&gt;
                                  &lt;asp:NumericPagerField /&gt;
                                  &lt;asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                      ShowNextPageButton="False" ShowPreviousPageButton="False" /&gt;
                              &lt;/Fields&gt;
                          &lt;/asp:DataPager&gt;
  
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/LayoutTemplate&gt;
  </code></pre>
  
  <p>my code behind for the button and changing the page size is:</p>
  
  <pre><code>    protected void PageSize_Changed(object sender, EventArgs e)
      {
          DataPager pager = ListView1.FindControl("DataPager1") as DataPager;
          if (string.IsNullOrEmpty(tb_page.Text) || tb_page.Text == "0")
          {
              label.Text = "Number required";
          }
          else
          {
              /*pager.PageSize = Convert.ToInt32(page_size_dropdown.SelectedValue);*/
              pager.PageSize = Convert.ToInt32(tb_page.Text);
              label.Text = "";
          }
      }
  
      protected void Bearbeitung_Click(object sender, EventArgs e)
      {
          DataPager pager = ListView1.FindControl("DataPager1") as DataPager;
  
          if (ListView1.Enabled == true)
          {
              ListView1.Enabled = false;
              cmdUpdate.Enabled = false;
              btn_Bearbeitung.Text = "Bearbeitung";
              cmdDelete.Enabled = false;
              LinqDataSource1.DataBind();
              ListView1.DataBind();
          }
          else
          {
              ListView1.Enabled = true;
              cmdUpdate.Enabled = true;
              cmdDelete.Enabled = true;
              btn_Bearbeitung.Text = "Disable Editing"; 
          }
      }
  </code></pre>
  
  <p>I have tried Datapager.Enabled = true; and variations of this but to no success. It doesn't seem to have an enabled property.</p>