I'm using a datapager control on my listview to perform paging in it.
When paging through the table, I need to perform some validations. When these validations are not successfull, the paging should be cancelled.
I currentl开发者_StackOverflow社区y perform the validation in the PagePropertiesChanging event of 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 canceling the paging is possible and how to perform it? Thanks
I too was disappointed to find there was no simpler way to do this. I ended up very much like Littlefool, where I made use of the PagePropertiesChanging
event. In it, if my validation did not pass, I called the SetPageProperties()
on my DataPager with a saved off value of its previous StartRowIndex
value, which I save off in the ViewState.
Not my proudest solution but it works.
Could you not simply manually page?
Eg Validate then page if OK, as opposed to try and page, validate, then cancel.
精彩评论