[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[asp.net+c#]如何引用repeater的header里的Label。

上一篇:[ms sql]SQL 优化
下一篇:[.net+c#]allowDefinition='MachineToApplication'错误,web.config

添加日期:2005/9/5 19:06:52 快速返回   返回列表 阅读5816次
不是在itemDataBound事件中。
=============================
经过试验,应该用rpResult.Controls,而不是rpResult.Items。

(Label)rpResult.Controls[0].FindControl("xxx") 就是了。

那么foot里的用
(Label)rpResult.Controls[rpResult.Controls.Count-1].FindControl("xxx") 应该也行吧。

下面是说明:

rpResult.Items里包含的是结果行,也就是
item.GetType=AlternatingItem 或Item

rpResult.Controls里包含的repeater里的所有控件。
如:
一个repeater的header里(表头里)有6个Label,
每行有11个Label,
下面是绑定第一行数据后用以下代码输出的:
============================================================
            for(int i=0;i<rpResult.Controls.Count;i++){
                Response.Write(rpResult.Controls[i].GetType()+"<br>");
                for(int j=0;j<rpResult.Controls[i].Controls.Count;j++){
                    Response.Write(rpResult.Controls[i].Controls[j].GetType()+"<br>");
                }
                Response.Write("<hr>");
            }
            foreach(RepeaterItem item1 in rpResult.Controls)
            {        
                Response.Write(item1.ItemType +"<br>");
            }
========================================================


System.Web.UI.WebControls.RepeaterItem
System.Web.UI.ResourceBasedLiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl

--------------------------------------------------------------------------------
System.Web.UI.WebControls.RepeaterItem
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl
System.Web.UI.WebControls.Label
System.Web.UI.LiteralControl

--------------------------------------------------------------------------------

Header
Item

 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved