ASP.NET中GridView、DataList、DataGrid三個(gè)數(shù)據(jù)控件foreach遍歷用法示例
本文實(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ì)有所幫助。
- asp.net實(shí)現(xiàn)固定GridView標(biāo)題欄的方法(凍結(jié)列功能)
- 在ASP.NET 2.0中操作數(shù)據(jù)之六十四:GridView批量添加數(shù)據(jù)
- 在ASP.NET 2.0中操作數(shù)據(jù)之十:使用 GridView和DetailView實(shí)現(xiàn)的主/從報(bào)表
- ASP.NET數(shù)據(jù)綁定GridView控件使用技巧
- ASP.NET數(shù)據(jù)綁定之GridView控件
- ASP.NET中GridView的文件輸出流方式
- asp.net GridView中使用RadioButton單選按鈕的方法
- asp.net Checbox在GridView中的應(yīng)用實(shí)例分析
- ASP.NET中GridView 重復(fù)表格列合并的實(shí)現(xiàn)方法
相關(guān)文章
MVC使用Controller代替Filter完成登錄驗(yàn)證(Session校驗(yàn))學(xué)習(xí)筆記5
這篇文章主要介紹了MVC使用Controller代替Filter完成登錄驗(yàn)證即Session校驗(yàn),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09
asp.net實(shí)現(xiàn)生成靜態(tài)頁(yè)并添加鏈接的方法
這篇文章主要介紹了asp.net實(shí)現(xiàn)生成靜態(tài)頁(yè)并添加鏈接的方法,非常實(shí)用的功能,需要的朋友可以參考下2014-07-07
Queryable.Union 方法實(shí)現(xiàn)json格式的字符串合并的具體實(shí)例
這篇文章介紹了Queryable.Union 方法實(shí)現(xiàn)json格式的字符串合并的具體實(shí)例,有需要的朋友可以參考一下2013-10-10
.net中string類型可以作為lock的鎖對(duì)象嗎
lock 關(guān)鍵字是用于在多線程編程中實(shí)現(xiàn)同步和互斥訪問(wèn)的關(guān)鍵字,它的作用是確保共享資源在任意時(shí)刻只能被一個(gè)線程訪問(wèn),從而避免出現(xiàn)競(jìng)態(tài)條件(race condition)和數(shù)據(jù)不一致的問(wèn)題,這篇文章主要介紹了string類型可以作為lock的鎖對(duì)象嗎,需要的朋友可以參考下2023-06-06
ASP.NET The system cannot find the file specified解決辦法
這篇文章主要介紹了ASP.NET The system cannot find the file specified解決辦法的相關(guān)資料,需要的朋友可以參考下2016-11-11

