我如何获得ASP.NET DataPager控件在一个UpdatePanel工作? [英] How do I get the ASP.NET DataPager control to work in an UpdatePanel?

查看:207
本文介绍了我如何获得ASP.NET DataPager控件在一个UpdatePanel工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有在顶部和在底部结果的搜索按钮参数的搜索页面。整个事情是包裹在母版页内更新面板。点击搜索按钮后,它显示的第一页。然而,如果你点击DataPager的下一个按钮,它不显示第二页。这显示没有结果的第二页。任何帮助将大大AP preciated。

I have a search page with parameters at the top and a search button with results at the bottom. The entire thing is wrapped in an update panel inside the master page. After clicking the search button it shows the first page. However if you click the next button on the DataPager it does not show the second page. It shows no results for the second page. Any help would be greatly appreciated.

推荐答案

我觉得尼克具有正确的想法。这听起来像您正在执行搜索和填充你的ListView在OnClick方法为您的搜索按钮。你需要(pferably或$ P $缓存中的数据在第一时间周围)进行搜索并绑定该给ListView为正在使用DataPager的要求每个新页面。

I think Nick has the right idea. It sounds like you are performing your search and populating your ListView in your OnClick method for your search button. You need to perform your search (or preferably cache the data the first time around) and bind that to the ListView for each new page that is requested using the DataPager.

您可以通过创建ListView的OnPagePropertiesChanged事件的方法做到这一点很容易。执行搜索(或从缓存中取出),绑定在OnPagePropertiesChanged事件的ListView和数据应填充。你的C#code可能是这样的:

You can do this fairly easily by creating a method for the ListView's OnPagePropertiesChanged event. Perform the search (or pull from the cache) and bind the ListView in that OnPagePropertiesChanged event and your data should populate. Your C# code might look like this:

protected void SearchButton_OnClick(object sender, EventArgs e)
{
    PerformSearch();
}

protected void PerformSearch()
{
    // ...Get your data.... //

    ListView1.DataSource = data;
    ListView1.DataBind();
}

protected void ListView1_OnPagePropertiesChanged(object sender, EventArgs e)
{
    PerformSearch();
}

这篇关于我如何获得ASP.NET DataPager控件在一个UpdatePanel工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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