我在webForm中添加了一个RadioButtonList控件,带有5个item,运行的时候,如果你选择了一个的话,运行正常,可是,如果一个都没有选择,则出现error。
我用button做的提交。
错误如下
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 58: else {RadioLabel.Text=MyJobRb.Text;}
行 59: //如果选择了mysturb,则RadioLabel的文本为MyJobRb.Text;
行 60: if (MyRBList.SelectedItem.Selected==true)
行 61: { ListLabel.Text=MyRBList.SelectedItem.Text;}
行 62: else ListLabel.Text="111";
源文件: c:\inetpub\wwwroot\aspx\singmutibuttons\webform1.aspx.cs 行: 60 堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
SingMutiButtons.WebForm1.SureBtn_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\aspx\singmutibuttons\webform1.aspx.cs:60
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
我用button做的提交。
错误如下
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。源错误:
行 58: else {RadioLabel.Text=MyJobRb.Text;}
行 59: //如果选择了mysturb,则RadioLabel的文本为MyJobRb.Text;
行 60: if (MyRBList.SelectedItem.Selected==true)
行 61: { ListLabel.Text=MyRBList.SelectedItem.Text;}
行 62: else ListLabel.Text="111";
源文件: c:\inetpub\wwwroot\aspx\singmutibuttons\webform1.aspx.cs 行: 60 堆栈跟踪:
[NullReferenceException: 未将对象引用设置到对象的实例。]
SingMutiButtons.WebForm1.SureBtn_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\aspx\singmutibuttons\webform1.aspx.cs:60
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
解决方案 »
- Mvc中的controller是不是没有子文件夹???就直接有homecontroller.cs等文件
- 关于TreeView的一个问题
- 请问如何将ASP.NET生成静态页面?
- 在线啊,在datagrid中dropdownlist引发事件使另一个dropdownlist的值变化?
- 请问用ASP.NET设计的页面能否在SOLARIS操作系统上正常显示(急!)
- 附加程序出错啊
- 【if(e.Item.Cells[3].Text.Trim() like "pc%")?】
- 关于BBS中文章存储字段的数据类型的问题!
- 请大家帮忙,我的visual.net2003无法建立asp.net web应用程序!报“web服务器运行的不是asp.net1.1版”该如何解决?
- 太急了,高手不帮我 我就玩完了
- 我做一个修改用户资料的页面,无法把修改后的信息写进数据库,其实数据是写进去了,但控件记住的是原来的状态,而不是当前的状态,望高人
- 数据库中字段为tinyint型,我保存时用int型,报错!(救我!)
===>
if (MyRBList.SelectedIndex>=0)
不过大哥,我将MyRBList的任意一个item的selected 设置为true重新运行也是可以的。
这2种方法有何区别呢?MyRBList.SelectedIndex>=0中>=0怎么解?