asp.net分页中的gridview [英] gridview in asp.net paging

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

问题描述

从2天以来,iam正在使用gridview控件工作..我有一个带有一个表的数据库..那个表可以有100条记录..我不想一次检索所有记录..我想检索记录仅基于页面大小...假设我的页面大小为10,我只想从数据库中检索0-9个记录中的记录..单击下一页后,我只想从数据库中检索10-19个记录像那样..任何人都可以帮助我解决这个问题..
谢谢

解决方案

请参考:
使用JQuery的客户端Gridview分页 [使用ASP.NET GridView进行自定义分页 [在GridView中使用jQuery Tooltip插件 [ ^ ]
带有PageSize更改下拉列表的GridView自定义分页 [ ^ ]
使用jQuery的TableSorter可分离的GridView [使用以下方法限制gridview的页面大小自定义分页 [ ^ ]


添加Gridview

 <   asp:gridview     id   ="   ="span>    runat   =" 服务器" 自动生成列  错误"  xmlns: asp   ="  > 
           宽度="100%" AllowSorting ="True" OnRowCommand ="DgTest_RowCommand"
           OnRowDataBound ="DgTest_RowDataBound" AllowPaging ="True"
           onpageindexchanging ="DgTest_PageIndexChanging" CaptionAlign ="Right">
            <  页面设置    ="  首页" 最后一页文本  >最后一个"  > 
               Mode ="NextPreviousFirstLast" NextPageText ="Next" PreviousPageText ="Previous"/>
           <   > 
               <   asp:boundfield    数据字段  ="  标题文字   Id " / <   asp:boundfield    数据字段  ="  标题文字  名称Emp"    / > 
           <  /列 > 
       <  /pagersettings  >  <  /asp:gridview  > 



将PageIndexChanging事件创建为

 受保护的 无效 DgTest_PageIndexChanging(对象发​​件人,GridViewPageEventArgs e)
        {
            DgTest.PageIndex = e.NewPageIndex;
            Populate();
        } 



 私有 无效 Populate()
        {
            // 要获取数据源到Databind的代码
        } 


1.请使用gridview allow分页属性= true
2.gridview页面索引更改事件


hai from since 2 days iam working with gridview control..i have a database with one table.. that table can have 100 records.. I dont want to retrive all the records at a time.. i wanted to retrive records based on the page size only... for suppose my page size is 10 i wanted to retrieve the records from 0-9 records only from database .. after am clicking on the next page i wanted to retrieve 10-19 records only from database as like that.. can any one help me for this problem..
Thank you

解决方案

Please refer:
Client Side Gridview Pagination using JQuery[^]
Custom paging with ASP.NET GridView[^]
Using the jQuery Tooltip Plugin in a GridView[^]
GridView Custom Paging with PageSize Change Dropdown[^]
Sortable GridView using jQuery''s TableSorter[^]

Similar discussion:
Limit pagesize of a gridview using custom paging[^]


Add Gridview

<asp:gridview id="DgTest" runat="server" autogeneratecolumns="False" xmlns:asp="#unknown">
           Width="100%" AllowSorting="True" OnRowCommand="DgTest_RowCommand"
           OnRowDataBound="DgTest_RowDataBound" AllowPaging="True"
           onpageindexchanging="DgTest_PageIndexChanging" CaptionAlign="Right">
            <pagersettings firstpagetext="First" lastpagetext="Last">
               Mode="NextPreviousFirstLast" NextPageText="Next"  PreviousPageText="Previous" />
           <columns>
               <asp:boundfield datafield="ID" headertext="Id" />
               <asp:boundfield datafield="NAME" headertext="Name of Emp" />
           </columns>
       </pagersettings></asp:gridview>



Create PageIndexChanging event as

protected void DgTest_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            DgTest.PageIndex = e.NewPageIndex;
            Populate();
        }



private void Populate()
        {
            //Code To get datasource to Databind
        }


1.please use gridview allow paging property=true
2.gridview pageindex changing event


这篇关于asp.net分页中的gridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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