日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

获取repeater控件模版列中的控件

發布時間:2025/3/15 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 获取repeater控件模版列中的控件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
直接用repeater.Findcontrol是獲取不到子控件的,因為子空間實際是在ItemTemplate中的,翻譯一個評論:
if(Roles.IsUserInRole("admin"))
{
Button delete = (Button)rptNotering.Items[0].FindControl("btnDelete");
delete.Visible = true;
Button edit = (Button)rptNotering.Items[0].FindControl("btnEdit");
edit.Visible = true;
}

Inside a repeater are 0-many Items. .Items[x] is where x is the index of the specific itemtemplate instance.
If your repeater returns 10 rows of data, then your repeater returns an instance of ItemTemplate 10 times
and places each instance in the Items[] collection.

Your findcontrol method is not looking inside the ItemTemplate.
Hope this helps :-)


大體意思是
:在repeater中有0項,Items[x] 才是制定模版列的實例,如果你的repeater有10行數據,那么你的repeater返回10次ItemTemplate 的實例,每個實例都是在item的集合眾的。

所以我在事件中作了,效果還是可以,只不過這樣的循環感覺不是很好,還有注意你要在repeater數據邦定后再來做如上操作,否則沒效果的。。。。

轉載于:https://www.cnblogs.com/Longkin/archive/2008/05/16/1200238.html

總結

以上是生活随笔為你收集整理的获取repeater控件模版列中的控件的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。