posts - 19,  comments - 3,  trackbacks - 0
ASP.NET 2.0,Repeater中FooterTemplate并无FindControl方法,也无法将FooterTemplate转成RepeaterItem,虽然在Repeater的ItemDataBound事件中,RepeaterItemEventArgs参数用if (e.Item.ItemType == ListItemType.Footer)可判别出这个Footer,但其他时候不行。

目前找到的方法如下:
CheckBoxList SampleCheckBoxList = FooRepeater.Controls[FooRepeater.Controls.Count - 1].FindControl("SampleCheckBoxList ") as CheckBoxList;

我在FooterTemplate放了一个CheckBoxList。

也就是说FooterTemplate是Repeater控件中的最后一个控件。
posted on 2007-07-23 20:31 Jeff Yang 阅读(256) 评论(2)  编辑 收藏

FeedBack:
2007-10-03 20:13 | 心海無涯      
無法取得,能否貼一下代碼,
HttpContext.Current.Response.Write(Repeater1.Controls.Count.ToString());結果為0;
其中
<FooterTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
請問是什麼原因?


  回复  引用  查看    
#2楼 [楼主]
2007-10-06 07:36 | Jeff Yang      
<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="C#" runat="server">
void Page_Load(Object Sender, EventArgs e) {
if (!IsPostBack) {
ArrayList values = new ArrayList();

values.Add(new PositionData("Microsoft", "Msft"));
values.Add(new PositionData("Intel", "Intc"));
values.Add(new PositionData("Dell", "Dell"));

Repeater1.DataSource = values;
Repeater1.DataBind();
}

Response.Write(Repeater1.Controls.Count);
}

public class PositionData {

private string name;
private string ticker;

public PositionData(string name, string ticker) {
this.name = name;
this.ticker = ticker;
}

public string Name {
get {
return name;
}
}

public string Ticker {
get {
return ticker;
}
}
}

</script>

</head>
<body>
<form id="form1" runat="server">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("name") %>' ToolTip='<%# Eval("ticker") %>'></asp:Label>
<br />
</ItemTemplate>
<FooterTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Text="Footer" ForeColor="red" />
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>
  回复  引用  查看    

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      


相关链接:
 




<2007年7月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

与我联系

搜索

 

常用链接

留言簿

随笔档案

最新评论

阅读排行榜

评论排行榜