如何在asp网格视图中获取值? [英] How to get values in a asp grid view?

查看:60
本文介绍了如何在asp网格视图中获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从网格视图控件中读取值?

  foreach (GridViewRow row  in  grdSearchresult.Rows)
{





}



这就是我在做什么,但问题是,它只提取以网格显示的项目,即我启用了分页,因此网格每页只显示10个项目。

以上代码只获取10个值,而不是我需要获取该网格中的所有记录。



例如:网格结果包含30条记录

由于启用了分页,它只会显示10个项目。所以当我循环遍历这10个项目时,我想循环遍历所有项目(在这种情况下为30项)。

解决方案

循环通过你绑定gridview的绑定源


嗨。,



在forea之前CH使用grdSearchresult.AllowPaging =假禁用寻呼;

<预郎= CS> grdSearchresult.AllowPaging = <跨度类= 代码关键字>假;
foreach (GridViewRow row in grdSearchresult.Rows)
{
}
grdSearchresult.AllowPaging = <跨度类= 代码关键字>真;



和foreach后使寻呼使用grdSearchresult.AllowPaging = true;



或将此gridview的数据源保存到hiddenfield或session并访问。


How to read the values from a grid view control ?

foreach (GridViewRow row in grdSearchresult.Rows)
              {



}

This is what am doing but the problem is, its fetching only items which are shown in grid, ie i have enabled pagination so grid will show only 10 items per page.
The above code is fetching only that 10 values but instead of that i need to fetch all the records in that grid.

Eg: Grid result contains 30 records
Since pagination is enabled it will show only 10 items.So when i do loop its looping through only this 10 items but i want to loop through all the items(in this case 30 items ).

解决方案

Loop through the binding source from which your are binding the gridview


Hi.,

Before foreach disable paging using grdSearchresult.AllowPaging = false;

grdSearchresult.AllowPaging = false;
foreach (GridViewRow row in grdSearchresult.Rows)
{
}
grdSearchresult.AllowPaging = true;


and after foreach enable paging using grdSearchresult.AllowPaging = true;

or Save the datasource of this gridview into a hiddenfield or session and access.


这篇关于如何在asp网格视图中获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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