ListView中的Datapager问题分页概念 [英] Datapager problem paging concept in listview

查看:57
本文介绍了ListView中的Datapager问题分页概念的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目中有ID和名称文本框.

如果我按ID搜索所有客户,则在3页中显示34条记录,如果我在数据寻呼机中查看第3页,并且如果我需要按名称搜索所有客户,则在2页中显示30条记录.

它显示当前记录的第二页而不是第一页,因为我查看的上一个记录是第三页,所以它占据了当前记录的最后一页.

如何解决此问题?

I have id and name textboxes in my project.

If I search all customer by id, it shows 34 records in 3 pages and if I view 3rd page in data pager and if I need to search all customer by name it shows 30 records in 2 page.

It shows the 2nd page of current record instead of 1st page, because the previous record I viewed was the 3rd page so it take the last page in current record.

How can I solve this problem?

推荐答案

尝试以下示例代码:


try this sample code:


<asp:GridView ID="grid_view" runat="server" AllowPaging="True" 
    AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" 
    BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" 
    GridLines="Vertical">
    <FooterStyle BackColor="#CCCCCC" />
    <Columns>
        <asp:BoundField DataField="adc" HeaderText="Posa No." />
        <asp:BoundField DataField="cde" HeaderText="Unit" />
        <asp:BoundField DataField="efg" HeaderText="User" />
        <asp:BoundField DataField="hj" HeaderText="Posa Date" />
    </Columns>
    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" /> 
    <AlternatingRowStyle BackColor="#CCCCCC" />
</asp:GridView>



请参考:
http://stackoverflow.com/questions/6798340/paging-problem-with-gridview



refer at:
http://stackoverflow.com/questions/6798340/paging-problem-with-gridview




在点击搜索按钮时,设置
Hi,

on click of your search button set
gridView.PageIndex =0;



希望对您有帮助,

谢谢
-amit.



hope this will help you,

thanks
-amit.


最后,我得到了我的问题的答案:


工作正常.

谢谢大家



ListView1.DataSource =详细信息;
ListView1.DataBind();
int CurrentPage = 0;
int PageSize = DataPagerId.PageSize;
DataPagerId.SetPageProperties(CurrentPage * PageSize,PageSize,true);
Finally i got the answer for my problem:


Its Working fine.

Thanks All



ListView1.DataSource = details;
ListView1.DataBind();
int CurrentPage = 0;
int PageSize = DataPagerId.PageSize;
DataPagerId.SetPageProperties(CurrentPage * PageSize, PageSize, true);


这篇关于ListView中的Datapager问题分页概念的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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