0
我正尝试将点击事件动态添加到中继器的项目中的表中,服务器端代码如下。但是,Findcontrol无法找到该项目中的控件...我做错了什么?Repeater上的Findcontrol无法找到控件
rownr = 0;
foreach (RepeaterItem ri in Lijst.Items)
{
string targ = "javascript:return GoAanvraag(" + rownr.ToString() + ");";
Table tb1 = ((Table) ri.FindControl("ItemTabel"));
tb1.Attributes.Add("onclick", targ);
rownr++;
}
直放站代码:
<asp:Repeater ID="Lijst" runat="server" DataSourceID="SqlDataSource2"
OnItemDataBound="Lijst_ItemDataBound"
>
<HeaderTemplate>
</HeaderTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
<ItemTemplate>
<table ID="ItemTabel" style="width:100%">
<tr>
<td style="width:100%">
<asp:Label ID="Regel" runat="server"></asp:Label>
</td>
<td style="width:100%">
<asp:Label ID="Plancode" runat="server" font-size="20px" align=right></asp:Label>
</td>
<asp:Button ID="btnGoAanvraag" runat="server" visible="false"/>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
谢谢,问题出在“runat”。我似乎总是忘记这一点,然后忘记我忘了))) – Jur