From everything I\'ve read, it seemed that adding paging to a ListView control should be dead simple, but it\'s not working for me. After adding the ListView and DataPager contr
Also, if the data source of your ListView is changed (e.g. if displaying data based on search parameters), don't forget to reset the pager every time the data source is updated. With a ListView this is not as straightforward as some other data-bound controls (e.g. GridView):
private void ResetListViewPager()
{
DataPager pager = (DataPager)ListViewMembers.FindControl("DataPager1");
if (pager != null)
{
CommandEventArgs commandEventArgs = new CommandEventArgs(DataControlCommands.FirstPageCommandArgument, "");
// MAKE SURE THE INDEX IN THE NEXT LINE CORRESPONDS TO THE CORRECT FIELD IN YOUR PAGER
NextPreviousPagerField nextPreviousPagerField = pager.Fields[0] as NextPreviousPagerField;
if (nextPreviousPagerField != null)
{
nextPreviousPagerField.HandleEvent(commandEventArgs);
}
// THIS COMMENTED-OUT SECTION IS HOW IT WOULD BE DONE IF USING A NUMERIC PAGER RATHER THAN A NEXT/PREVIOUS PAGER
//commandEventArgs = new CommandEventArgs("0", "");
//NumericPagerField numericPagerField = pager.Fields[0] as NumericPagerField;
//if (numericPagerField != null)
//{
// numericPagerField.HandleEvent(commandEventArgs);
//}
}
}