title: Set GridView PageSize from Jquery
body: <p>I want to set the PageSize from a JQuery, the reson is that the gridView have a diffrent height on diffrent screens.</p>
  
  <p>here is the Jquery i run on the page and the GridView</p>
  
  <pre><code>&lt;script&gt;
       //Initial load of page
       $(document).ready(sizePage);
  
       //Every resize of window
       $(window).resize(sizePage);
  
       //Dynamically assign height
       function sizePage() {
           var newHeight = $("#page").height() / 1.5;
           $("#mid").css("height", newHeight + "px");
           $("#box1").css("height", newHeight + "px");
           $("#box2").css("height", newHeight + "px");
           $("#field2").css("height", newHeight - 80 + "px");
           $('#&lt;%= GridView.ClientID %&gt;').attr("PageSize", "5");
       }
  &lt;/script&gt;
  
  
  &lt;asp:GridView ID="GridView" CssClass="tekst" Width="100%" runat="server" AllowPaging="true" AutoGenerateColumns="false" BorderWidth="0px" GridLines="None" OnPageIndexChanging="GridView_PageIndexChanging" OnRowCommand="GridView_RowCommand" OnRowDataBound="GridView_RowDataBound"&gt;
  &lt;Columns&gt;
      &lt;asp:BoundField DataField="nyhed_overskrift" HeaderText="Title" HeaderStyle-HorizontalAlign="Left" HeaderStyle-CssClass="headcontent2" /&gt;
      &lt;asp:BoundField DataField="nyhed_dato" HeaderText="Oprettet" HeaderStyle-Width="80" ItemStyle-HorizontalAlign="Center" HeaderStyle-CssClass="headcontent2" /&gt;
      &lt;asp:BoundField DataField="nyhed_id" HeaderText="ID" HeaderStyle-CssClass="invis" HeaderStyle-Width="0" ItemStyle-CssClass="invis" ItemStyle-Width="0" /&gt;
      &lt;asp:ButtonField ButtonType="Image" ImageUrl="Image/Diverse/Arrow.png" CommandName="LaesNyhed" HeaderStyle-Width="50px" /&gt;
  &lt;/Columns&gt;
  &lt;PagerStyle VerticalAlign="Bottom" HorizontalAlign="Center" CssClass="tekst" /&gt;
  &lt;/asp:GridView&gt;
  </code></pre>