我有一个自定义DropDownList控件,SDropDownList。我正在尝试注册并激发“SelectedIndexChanged”事件。我明显是通过向标记添加OnSelectedIndexChanged =“method”属性开始的,但它不会触发事件。我也试图对其进行注册程序中RepeaterDropDownList事件不在中继器内触发
protected void rptrSection1_Bound(object sender, RepeaterItemEventArgs e)
{
var ctl = e.Item.FindControl("ddlS1") as SDropDownList;
ctl.SelectedIndexChanged += new EventHandler(ddlS1_SelectedIndexChanged);
}
注意的OnBound事件: 我读了表明禁用的Repeater ViewState中会解决这个问题的一些不同的论坛帖子。这不适合我。
感谢您的帮助!
按照要求,标记:
<asp:Panel ID="pnlSection1" runat="server">
<asp:Repeater ID="rptrSection1" runat="server" OnItemCommand="rptrSection1_Command"
OnItemDataBound="rptrSection1_Bound">
<ItemTemplate>
<table class="Section2Table" cellspacing="3">
<tr>
<td class="simgv" style="padding: 3px">
<sc:SDropDownList ID="ddlS1" runat="server" OnSelectedIndexChanged="ddlS1_SelectedIndexChanged" >
<asp:ListItem Text="Compliant" Value="0" />
<asp:ListItem Text="Other Than Serious" Value="1" />
<asp:ListItem Text="Serious" Value="2" />
<asp:ListItem Text="Critical" Value="3" />
</sc:SDropDownList>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
您可以发布控件所在的标记吗? – Oded 2010-11-13 20:29:30