网格视图 - 在c#.net中进行分页时查找最后一行 [英] grid view - find last row when we do paging in c#.net

查看:71
本文介绍了网格视图 - 在c#.net中进行分页时查找最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我的aspx页面中有一个网格,并设置允许分页=真



现在我想获取最后一页的最后一行记录。



i尝试使用以下代码获得第1行记录,



Hi am having a grid in my aspx page, and set "Allow paging= true"

Now i want to get the last row record of the last page.

i tried the following code to get the 1st row record,

GridViewRow FirstRow = gdvData.Rows[0];//getting 1st row of 1st page working fine

GridViewRow LastRow = gdvData.Rows[gdvData.Rows.Count - 1];//getting last row of last page is not works





Ex。网格包含6页,我想要检索第6页的最后一条记录。



上面的代码检索第1页的最后一条记录但是我想要仅排在第6页的最后一行



任何想法?



Ex. grid contains 6 pages, i want to retrieve last record of the 6th page.

The above code retrieve the last record of the 1st page but here i want last row of 6th page only.

any idea?

推荐答案

首先你需要取消你的网格视图。

试试这个:

First you need to unpage your grid view.
Try this:
 this.gdvData.AllowPaging = false;
 this.gdvData.AllowSorting = false;
 this.gdvData.EditIndex = -1;
// Let's bind data to GridView
 this.RefreshGrid();
GridViewRow FirstRow = gdvData.Rows[0];//getting 1st row of 1st page working fine
                
GridViewRow LastRow = gdvData.Rows[gdvData.Rows.Count - 1];//getting last row of last page is not works
            this.gdvData.AllowPaging = true;
            this.gdvData.AllowSorting = true;
            this.gdvData.EditIndex = -1;





你将取消网格视图的页面,获取最后一行和然后再次翻页。

我希望这对你有帮助!



Fist you will un-page your gridview, get the last row and then page it again.
I hope this will help you!


这篇关于网格视图 - 在c#.net中进行分页时查找最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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