应用过滤器后重置listview的listview [英] Reset pageindex for listview after applying filter

查看:80
本文介绍了应用过滤器后重置listview的listview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在vb.net开发网站。我使用Listview来显示产品。有几个过滤器可以优化搜索。我在一页上展示了36种产品。共有450个产品在数据库中。问题是如果我切换到第1页到第10页&然后从checkboxList&中应用任何过滤器在应用过滤器之后,它找到了10个产品,然后显示空白结果,但是10个产品在那里,但它仍然在第10页,所以没有显示10个产品,因为它在第1页。可以任何人帮助我如何应用过滤器后休息pageIndex? OnPagePropertiesChanged我尝试在listview获取绑定后重置页面索引,但它无法正常工作。



我尝试过:



 受保护的  Sub  OnPagePropertiesChanging (发件人作为 对象,e 作为 PagePropertiesChangingEventArgs )
TryCast (products.FindControl( DataPager1),DataPager).SetPageProperties(e.StartRowIndex,e.MaximumRows, False
.buildWhereClause()
products.SelectedIndex = -1
结束 Sub

解决方案

您只需要重新填充 ListView 使用更新的数据源来反映您在分页和过滤后的更改。



如果您想重置页面后过滤然后您可能需要在CheckBoxList更改事件中编写逻辑,并执行以下操作:



 DataPager pager = ListView1。 FindControl(  DataPagerId as  DataPager ; 
if (pager!= null
{
pager。 SetPageProperties( 0 ,pager.PageSize, true );
}





VB.NET

  Dim  pager  As  DataPager =  TryCast (ListView1.FindControl(   DataPagerId),DataPager)
如果 pager IsNot 没什么 然后
pager.SetPageProperties( 0 ,pager.PageSize, True
结束 如果

' ========================================= ================
' 服务由Telerik提供(www.telerik.com)
' 转换由NRefactory提供。
' Twitter:@telerik
' Facebook:facebook.com/telerik
' ============================== =========================


I am developing website in vb.net. I have used Listview to display products. There are couple of filters to refine search. I am showing 36 products in one page & have total 450 products in database. Problem is if I switched to page 1 to page 10 & then apply any filter from checkboxList & after applying filter it found 10 products then it shows blanks result but 10 product is there but it still on 10th page so not showing 10 products because it is on 1st page. Can any one help me how can I Rest pageIndex after applying filter? OnPagePropertiesChanged I tried to reset page Index after listview gets bind but it is not working.

What I have tried:

Protected Sub OnPagePropertiesChanging(sender As Object, e As PagePropertiesChangingEventArgs)
        TryCast(products.FindControl("DataPager1"), DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
        Me.buildWhereClause()
        products.SelectedIndex = -1
    End Sub

解决方案

You just need to re-populate your ListView with the updated datasource to reflect the changes after you paged and filter.

If you want to reset the page after filtering then you may need to write the logic at CheckBoxList changed event instead, and do something like this:

DataPager pager = ListView1.FindControl("DataPagerId") as DataPager;
if (pager != null)
{
    pager.SetPageProperties(0, pager.PageSize, true);
}



VB.NET

Dim pager As DataPager = TryCast(ListView1.FindControl("DataPagerId"), DataPager)
If pager IsNot Nothing Then
	pager.SetPageProperties(0, pager.PageSize, True)
End If

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik
'Facebook: facebook.com/telerik
'=======================================================


这篇关于应用过滤器后重置listview的listview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆