gpt4 book ai didi

ASP.NET中GridView、DataList、DataGrid三个数据控件foreach遍历用法示例

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 28 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章ASP.NET中GridView、DataList、DataGrid三个数据控件foreach遍历用法示例由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

本文实例讲述了ASP.NET中GridView、DataList、DataGrid三个数据控件foreach遍历用法。分享给大家供大家参考,具体如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//gridview遍历如下:
foreach (GridViewRow row in GridView1.Rows)
{
   CheckBox cb = (CheckBox)row.FindControl( "CheckBox2" );
   if (cb.Checked == true )
   {
   }
}
//datagrid遍历:
foreach (DataGridItem oItem in ItemsGrid.Items)
{
   CheckBox ck1 = (CheckBox)oItem.FindControl( "CheckBox" );
   if (ck1.Checked == true )
   {
   }
}
//datalist遍历
foreach (DateListItem dl in DataList1.Items)
{
   CheckBox cb = (CheckBox)dl.FindControl( "CheckBoxID " );
   if (cb. checked )
   ......
}

GridView

?
1
2
3
4
for ( int i=0; i <GridView.Rows.Count;i++)
{
    Label lbl = (Label)GridView.Rows[i].FindControl( "Label9" );
}

Repeater

?
1
2
3
4
for ( int i=0; i < Repeater.Items.Count;i++)
{
   Label lbl = (Label) Repeater.Items[i].FindControl( "Label9" );
}

DataList

?
1
2
3
4
for ( int i=0; i < DataList.Items.Count;i++)
{
   Label lbl = (Label) DataList.Items[i].FindControl( "Label9" );
}

希望本文所述对大家asp.net程序设计有所帮助.

最后此篇关于ASP.NET中GridView、DataList、DataGrid三个数据控件foreach遍历用法示例的文章就讲到这里了,如果你想了解更多关于ASP.NET中GridView、DataList、DataGrid三个数据控件foreach遍历用法示例的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com