Paging would only work if we bind the listview to the datasource in the dataPager's Prerender event.
So the first option that strikes me , is to place the Listview bind call in a separate function
<asp:DataPager ID="DataPagerSampleData" runat="server" PagedControlID="lvSampleData"
PageSize="3" OnPreRender="DataPagerSampleData_PreRender">
<Fields>
..
</Fields>
</asp:DataPager>
And the prerender method would call the binddata function.
protected void DataPagerSampleData_PreRender(object sender, EventArgs e)
{
binddata();
}
private void binddata()
{
this.lvSampleData.DataSource = db.GellAll();
this.lvSampleData.DataBind();
}
and in the button click, set the pageproperties to the current index. I think that should trigger the PreRender method of the datapager. If it does not call binddata() method.
protected void button_click(object sender, EventArgs e)
{
int PageSize = DataPagerSampleData.PageSize;
DataPagerSampleData.SetPageProperties(currentpageindex * PageSize, PageSize, true);
}
I will let you know more when i do a sample with this.