欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET中GridView、DataList、DataGrid三個(gè)數(shù)據(jù)控件foreach遍歷用法示例

 更新時(shí)間:2016年08月05日 09:18:29   作者:Quber  
這篇文章主要介紹了ASP.NET中GridView、DataList、DataGrid三個(gè)數(shù)據(jù)控件foreach遍歷用法,結(jié)合實(shí)例形式分析了GridView、DataList、DataGrid使用foreach及for語(yǔ)句進(jìn)行數(shù)據(jù)遍歷的具體使用方法,需要的朋友可以參考下

本文實(shí)例講述了ASP.NET中GridView、DataList、DataGrid三個(gè)數(shù)據(jù)控件foreach遍歷用法。分享給大家供大家參考,具體如下:

//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:

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

Repeater:

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

DataList:

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

更多關(guān)于asp.net相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《asp.net操作json技巧總結(jié)》、《asp.net字符串操作技巧匯總》、《asp.net操作XML技巧總結(jié)》、《asp.net文件操作技巧匯總》、《asp.net ajax技巧總結(jié)專題》及《asp.net緩存操作技巧總結(jié)》。

希望本文所述對(duì)大家asp.net程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論