在DataList、Repeater的HeaderTemplate和FooterTemplate模板中寻找控件FindControl
【程序代码】
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="AAAAAAA"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("name") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:Label ID="Label3" runat="server" Text="BBBBBBB"></asp:Label>
</FooterTemplate>
</asp:Repeater>
【下边代码示例寻找Label1和Label3】
【程序代码】
//在HeaderTemplate中寻找Label1,默认为第0个
string s=((Label)Repeater1.Controls[0].FindControl("Label1")).Text;
//在FooterTemplate中寻找Label2,默认为最后一个
string s=((Label)Repeater1.Controls[Repeater1.Controls.Count - 1].FindControl("Label2")).Text;
在DataList、Repeater的HeaderTemplate和FooterTemplate模板中寻找控件FindControl的更多相关文章
- WPF备忘录(5)怎样修改模板中的控件
首先,想问大家一个问题,你们如果要给一个Button添加背景图片会怎么做?(呵呵,这个问题又点小白哈) 是这样吗? <Button Height="57" Horizonta ...
- WPF关于控件 父级控件,子级控件,控件模板中的控件,等之间的相互访问
原文:WPF关于控件 父级控件,子级控件,控件模板中的控件,等之间的相互访问 1,在菜单中访问 弹出菜单的控件 var mi = sender as MenuItem;//菜单条目 MenuItem ...
- DataList分页访问FooterTemplate模板里的控件
今天做DataList分页的时候,突然想把分页控件写在FooterTemplate模板里面,弄了很久都访问不到控件,终于发现问题所在,以下是访问FooterTemplate里控件的方法: <Fo ...
- UWP 查找模板中的控件
这个标题我也不知道咋起,意思说一下你就明白. 1. 对官方控件的模板进行定制修改,以满足多样化需求,还有漂亮的UI 比如ListView,GridView等. 2. 在设计的情况下并没有这个控件,而在 ...
- WPF 获取控件模板中的控件
DG是控件名称public T GetVisualChild<T>(DependencyObject parent, Func<T, bool> predicate) wher ...
- WPF日积月累之DataGrid样式以及操作数据模板中的控件
一.效果图 二.代码预览 1 <Window x:Class="Test.MainWindow" 2 xmlns="http://schemas.microsoft ...
- 【WPF】创建基于模板的WPF控件(经典)
原文:[WPF]创建基于模板的WPF控件(经典) WPF可以创建两种控件,它们的名字也很容易让人混淆:用户控件(User Control)和定制控件(Customer Control),之所以如此命名 ...
- 从外部访问 Template (模板)的控件、获取它的属性值
DataTemplate 和 ControlTemplate 两个类均派生自 FrameWorkTemplate类.这个类有个 FindName方法 供我们查询内部控件. ControlTempla ...
- 在FooterTemplate内显示DropDownList控件
如果想在Gridview控件FooterTemplate内显示DropDownList控件供用户添加数据时所应用.有两种方法可以实现,一种是在GridView控件的OnRowDataBound事件中写 ...
随机推荐
- my PhoneWeb
<meta name="viewport" content="width=device-width, user-scalable=yes, minimum-scal ...
- 使用密钥验证方式登录linux系统
1.使用PuTTY工具PuTTYgen生成密钥对,打开PuTTYgen,点击Generate生成公钥(生成过程动动鼠标会提升进度哦). 2.将公钥(蓝色的是私钥)放到服务器上去: -在/root目录下 ...
- 第3章 rpm命令管理
3-1 RPM包命名规则 3-2 安装命令 3-3 升级与卸载 3-4 RPM包查询 3-5 RPM包校验
- Linux应用程序的地址布局
转载自:http://blog.csdn.net/embedded_hunter http://www.360doc.com/content/12/0405/00/1671317_200882538. ...
- read the python code and predict the results --- from <Learn Python The Hard Way>
import random from urllib import urlopen import sys WORD_URL = "http://learncodethehardway.org/ ...
- JVM ,JIT ,GC RUNTIME 解析
Java Class字节码知识点回顾 https://yq.aliyun.com/articles/2358?spm=5176.8067842.tagmain.105.fQdvH3 JVM Class ...
- Improve Scalability With New Thread Pool APIs
Pooled Threads Improve Scalability With New Thread Pool APIs Robert Saccone Portions of this article ...
- linux oracle profile配置
[oracle@db01 ~]$ more .bash_profile # .bash_profile # Get the aliases and functionsif [ -f ~/.bashrc ...
- 二十四种设计模式:组合模式(Composite Pattern)
组合模式(Composite Pattern) 介绍将对象组合成树形结构以表示"部分-整体"的层次结构.它使得客户对单个对象和复合对象的使用具有一致性.示例有一个Message实体 ...
- 用Javascript弹出div定义的消息框并往块里面填写文字
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...