分页时在gridview中获取键值的问题 [英] problem in getting key value in gridview while paging

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

问题描述

问题是:

我有一个绑定到9条记录的gridview&它的allowpaging为true,并且我使用pageindexchanging事件进行了分页.页面大小为3.

现在在第二页上有3条记录,其原始索引为3,4,5 ....

但我想将getindex作为第二页的第一行clickde,然后像智慧的那样得到0索引.那么代码是什么呢?

The Problem is:

i have a gridview to bind with 9 records & its allowpaging is true and i did paging with pageindexchanging event. page size is 3.

now on 2nd page there are 3 record which original index is 3,4,5....

but i want to getindex as 2nd page''s first row clickde then i get 0 index like wise. so what is the code?

推荐答案

当然,每页第一行的索引为零:gridview本身会返回该索引,并且不知道它是分页的:它只知道它有3个条目,并返回适合的索引.如果需要引用特定的行,则需要在表格中包括表ID(可以将其隐藏)以标识要选择的确切行.否则,索引将根据Gridview的排序和过滤方式而改变-这使得从用户在GridView中选择的行中识别数据库表中的特定行变得更加困难.
Of course the index is zero for the first row of each page: the gridview itself returns this, and does not know it is paged: it just knows it has 3 entries, and returns an index that fits that. If you need to refer to a specific row, then you need to include the table ID in the grid (it can be hidden) to identify the exact row you are selecting. Otherwise, the index will change according to how the Gridview is sorted, and filtered - which makes it a lot harder to identify a specific row in a database table from the row selected in the GridView by the user.


这篇关于分页时在gridview中获取键值的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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