---
title: "ListView and DataPager not working"  
description: "ListView and DataPager not working"  
author: "Anonymous User"  
published: 2014-08-25  
updated: 2014-08-25  
canonical: https://www.mindstick.com/forum/2121/listview-and-datapager-not-working  
category: "asp.net"  
tags: ["asp.net"]  
reading_time: 1 minute  

---

# ListView and DataPager not working

I used a DataPager to [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) through [ListView](https://www.mindstick.com/articles/12744/listview-in-android) [data](https://www.mindstick.com/articles/13050/salesforce-aiming-to-dominate-predictive-analytics-with-data-science). When ListView bound, DataPager show many pages below, everything seems to be ok but when i click to another page, After a [postback](https://www.mindstick.com/blog/342/postback-in-asp-dot-net), ListView is empty with EmptyDataTemplate and of course without pages.

```
    protected void DatapPager_OnPreRender(object sender, EventArgs e)    {        try        {            listView.DataSource = ((DataSet)ViewState[VIEWSTATE_DATASET]).Tables[0];            listView.DataBind();        }        catch (System.Exception ex)        {                       }                    base.OnPreRender(e);    }     protected void listView_OnPagePropertiesChanged(object sender, EventArgs e)    {        try        {            listView.DataSource = ((DataSet)ViewState[VIEWSTATE_DATASET]).Tables[0];            listView.DataBind();        }        catch (System.Exception ex)        {                       }                }
```

In my case, ListView's data bound in a [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event), not on PageLoad.

[Anyone](https://www.mindstick.com/articles/23207/how-to-find-the-best-fit-job-for-anyone) can helps me? Thank you so much!

## Replies

### Reply by Sumit Kesarwani

Hi jay,

Its Simple, Just Get "ID" in "QUERY-STRING" from the Database, Now Set it to the Pager Control Property as [QueryStringField="ID"] like:

```
<asp:DataPager ID="DataPagerProducts" runat="server" QueryStringField="ID" PageSize="3">                           
<Fields>                               
<asp:NextPreviousPagerField ShowFirstPageButton="True"
ShowNextPageButton="False" />                                <asp:NumericPagerField />                               
<asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />                           
</Fields>                       
</asp:DataPager>
```


---

Original Source: https://www.mindstick.com/forum/2121/listview-and-datapager-not-working

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
