radiobuttonlist
我在页面后面的代码中附加事件,单选按钮列表在
listview
.当我运行程序时它会生成一个错误:
“对象引用未设置为对象的瞬间”
.aspx 代码:
<asp:ListView ID="ListView1" runat="server" >
<ItemTemplate>
<tr><td>
<asp:RadioButtonList ID="radiobuttonlist4" runat="server" AutoPostBack="true"
RepeatDirection="Horizontal"
OnSelectedIndexChanged="selected" Width="240px">
<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>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
.aspx.cs 代码
assessdal s = new assessdal();
ListView1.DataSource = s.showop1();
ListView1.DataBind();
RadioButtonList list= ListView1.FindControl("radiobuttonlist4") as RadioButtonList;
list.SelectedIndexChanged += new EventHandler(handle);
public void handle(object sender, EventArgs e)
{
Label2.Text = "y";
}