可以使用DataPager取消ListView中的分页
我在列表视图上使用数据分页器控件来在其中执行分页。
当翻阅表格时,我需要执行一些验证。当这些验证不成功时,应该取消寻呼。
我当前在 ListView 的 PagePropertiesChanging 事件中执行验证,但是参数不提供 Cancel 属性。
protected void MyListView_PagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e)
{
if (!Validate())
{ // cancel the paging action}
}
有谁知道是否可以取消寻呼以及如何执行? 谢谢
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 currently 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不能直接手动翻页吗?
例如,如果正常则验证然后寻呼,而不是尝试寻呼、验证然后取消。
Could you not simply manually page?
Eg Validate then page if OK, as opposed to try and page, validate, then cancel.
我也很失望地发现没有更简单的方法可以做到这一点。我最终的结果与 Littlefool 非常相似,我使用了
PagePropertiesChanging
事件。在其中,如果我的验证未通过,我会在 DataPager 上调用SetPageProperties()
,并保存其先前StartRowIndex
值的关闭值,该值保存在视图状态。这不是我最自豪的解决方案,但它确实有效。
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 theSetPageProperties()
on my DataPager with a saved off value of its previousStartRowIndex
value, which I save off in the ViewState.Not my proudest solution but it works.