I used a DataPager to page through ListView data. When ListView bound, DataPager show many pages below, everything seems to be ok but when i click to another page, After a postback, 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, not on PageLoad.
Anyone can helps me? Thank you so much!
Sumit Kesarwani
25-Aug-2014Its Simple, Just Get "ID" in "QUERY-STRING" from the Database, Now Set it to the Pager Control Property as [QueryStringField="ID"] like: