如何限制gridview中每页的行数 [英] How to restrict rows per page in gridview

查看:75
本文介绍了如何限制gridview中每页的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Gridview之一中我想每页只显示3条记录。我尝试使用以下代码但未按预期工作。它显示了5行。

In one of Gridview I want to show only 3 records per page. I tried with the following code but not working as expected. It shows 5 rows instead.

<asp:GridView ID="GridView3" runat="server" HorizontalAlign="Center"  AutoGenerateColumns="False"
                style="border-color: #808000; top: 450px; left: 515px; position: absolute; height: 84px; width: 384px"
                PageSize="3"
                onselectedindexchanged="GridView3_SelectedIndexChanged">

推荐答案

<asp:gridview id="GridView3" runat="server" horizontalalign="Center" autogeneratecolumns="False" style="border-color: #808000; top: 450px; left: 515px; position: absolute; height: 84px; width: 384px" pagesize="3" allowpaging="true" onpageindexchanging="GridView3_PageIndexChanging" onselectedindexchanged="GridView3_SelectedIndexChanged" xmlns:asp="#unknown">
 </asp:gridview>





实施pageindex更改如下





Implement pageindex changing as below

protected void GridView3_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
   /*Fill Gridview*/
   GridView3.PageIndex = e.NewPageIndex;
   GridView3.DataBind();
}


PageSize属性通常用于您需要的功能。但如果它不起作用,请检查Java脚本问题的aspx页面,以防你在页面上使用JS ..如果不是右键单击gridview并选择属性,那么将PageSize属性更改为3 ...正如我已经注意到,有时Visual Studio 2010并没有暗示这些属性如果用源代码写的...... :(



希望它能解决你的问题。



问候。
PageSize Property is normally used for the functionality you required. but if it is not working than do check the aspx page for Java Script Issue in case you are using JS on the page.. and if not than right click on the gridview and select properties and there change the PageSize property to 3... as I have noticed that sometimes Visual Studio 2010 didnt imply the properties if written in source... :(

Hope it will solve your problem.

Regards.


PageSize 是可用于设置数量的属性每页记录。从上面给出的代码,我看到它被提到。但是你还需要设置gridview的 AllowPaging =true属性。看看它是否设置此属性后工作。如果没有,请回复。
PageSize is the property that can be used to set the number of records per page. From your code given above, I see that it is mentioned. However you also need to set, AllowPaging = "true" property of the gridview. See if it works after setting this property. Reply back if it does not.


这篇关于如何限制gridview中每页的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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