It is possible to cancel paging in ListView using DataPager

I am using a datapager control on my list to do the paging in it.

When paging through a spreadsheet, I need to do some checks. When these checks are not successful, paging should be canceled.

I am currently validating on the PagePropertiesChanging event on the ListView, however the arguments do not provide a Cancel property.

protected void MyListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
     if (!Validate())
     { // cancel the paging action}
} 

      

Does anyone know if it is possible to undo the paging and how to accomplish it? Thanks to

+2


a source to share


2 answers


I was also disappointed that there wasn't an easier way to do this. I was very much like Littlefool where I used event PagePropertiesChanging

. In this case, if my validation failed, I called SetPageProperties()

on my DataPager with its previous value StartRowIndex

stored, which I store in the ViewState.



Not my proud solution, but it works.

0


a source


Can't you just manually create the page?



For example, Check if OK, as opposed to Try and Check, then cancel.

0


a source







All Articles