<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound1">
<ItemTemplate>
<tr id = "row" runat="server">
</ItemTemplate>
</asp:Repeater>
</div>
</asp:Content>然后我在Repeater1_ItemDataBound1事件中
用
HtmlTableRow row = (HtmlTableRow)e.Item.FindControl("row");
这个方法取不出值来,如果不用母版页就能取出来。 各位谢谢了,网上搜索了很久也没找到答案!!
tmlTableRow row = (HtmlTableRow)e.Item.Controls[0].FindControl("row");
Content con = (Content)Page.FindControl("Content1");这样都找不到,不知道为什么 找Content控件!
ContentPlaceHolder con = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1");
if (con == null)
{
return;
}
else
{
BindData();
Repeater rt = (Repeater)con.FindControl("Repeater1");
for (int i = 0; i < rt.Items.Count;i++ )
{
HtmlControl a = (HtmlControl)rt.Items[i].FindControl("row1");
}
}