Note that there are some explanatory texts on larger screens.

plurals
  1. POAsp.net/c# -> Gridview Pager doesn't get updated when gridview rows are filtered (or hidden)
    text
    copied!<p>I have the below code where I have some conditions because of which I have to hide the row from showing to end user. "ShowRow" is a boolean value that gets set in GetUnitOfMeasure function (not copied here) based on these conditions.</p> <p>There are some real conditions which is forcing me to hide. I tried to include them while building data source but I have to hide it before display.</p> <p>Problem I am facing is the paging is not getting refreshed based on total rows shown at the end. For example, if I have TOTAL of 200Rows in the grid and only 2 rows needs to be shown and if these 2 rows are found in paging 3, then when page is loaded it still shows paging 1 2 3 4 and 3rd page has the valid 2 rows. </p> <p>Please suggest.I have also used "onDataBound" against gridview (not copied here) but I just hide some columns here.</p> <p><strong>ASPX page</strong></p> <pre><code>&lt;asp:GridView ID="SearchResults" runat="Server" AutoGenerateColumns="false" EnableViewState="false" AllowPaging="true" PageSize="50" OnDataBound ="SearchResults_DataBound" OnRowDataBound="SearchResults_RowDataBound"&gt; &lt;RowStyle CssClass="EvenRow" /&gt; &lt;AlternatingRowStyle CssClass="OddRow" /&gt; &lt;Columns&gt; &lt;asp:TemplateField meta:resourceKey="UmSellField"&gt; &lt;ItemStyle CssClass="alpha" /&gt; &lt;HeaderStyle CssClass="alpha" /&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID="UmSellLabel" runat="server" EnableViewState="false" Text='&lt;%# GetUnitOfMeasure(Container.DataItem,false) %&gt;'&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; </code></pre> <p><strong>codebehind</strong></p> <pre><code>protected void SearchResults_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType.Equals(DataControlRowType.DataRow)) { e.Row.Visible = showRow; e.Row.Cells[0].Visible = showRow; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload