我在 listview 的 SlectedIndexChanged 事件中将 OnSelectedIndexChanged 事件与 RadioButtoList (即在 ListView 内)附加,当我运行程序时,单击 RadioButton,即使我为这个特定的事件触发实现了所有代码,也没有事件触发。但是没有语法或编译错误。告诉我我针对哪个 ListView 或 RadioButtonList 调用什么类型的事件?
.aspx 代码:
<asp:ListView ID="ListView1" runat="server" >
<itemtemplate>
<asp:RadioButtonList ID="radiobuttonlist4" runat="server" AutoPostBack="true" RepeatDirection="Horizontal" Width="240px" onselectedindexchanged="selected">
<asp:ListItem Value="agree" ></asp:ListItem>
<asp:ListItem Value="disagree"></asp:ListItem>
<asp:ListItem Value="strongagree"></asp:ListItem>
<asp:ListItem Value="strongdisagree"></asp:ListItem>
</asp:RadioButtonList>
</itemtemplate>
</listview>
代码背后:
protected void selected(object sender, EventArgs e)
{
RadioButtonList listtt = (RadioButtonList)sender;
ListViewItem item = (ListViewItem)listtt.NamingContainer;
RadioButtonList er = (RadioButtonList)item.FindControl("radiobuttonlist4");
er.SelectedIndexChanged += new EventHandler(handle);
}
public void handle(object sender, EventArgs e)
{
Label3.Text = "hjeje";
}