且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在asp网格视图中获取值?

更新时间:2023-10-19 20:46:04

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


嗨。,



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

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.