【发布时间】:2012-06-04 22:35:00
【问题描述】:
我在页面后面的代码中使用radiobuttonlist 附加事件,单选按钮列表位于alistview 内。当我运行程序时,它会生成一个错误:
“对象引用未设置为对象的瞬间”
.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";
}
【问题讨论】:
-
请格式化您的代码,Listview的哪个模板是RadioButtonList?
-
soory,.aspx 代码中有单选按钮列表控件,在复制代码时,它被遗漏了..
-
@user1405508:你为什么不正确地编辑你的问题?所以其他人可以提供帮助!
-
@user1405508:你想在哪里找到你的 RadioButtonList?你已经展示了你的代码隐藏在哪里?
标签: c# asp.net .net radiobuttonlist