在位置 0 处没有任何行。

今天,程序突然出现下面的错误:

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.IndexOutOfRangeException: 在位置 0 处没有任何行。

源错误:

“/auto.dg.gd.cn”应用程序中的服务器错误。

在位置 0 处没有任何行。

32 : private void Data_Binding()
33 : ... {
34:DataRowdr=objSynopsis.GetSynopsisByMember(_memberKey).Rows[0];
35:this.lblCompanyName.Text=dr["CompanyName"].ToString();
36:this.lblAddress.Text=dr["Address"].ToString();

源文件: d:\auto.dg.gd.cn\CheHang\CheHangPageFooter.ascx.cs 行: 34

堆栈跟踪:

[IndexOutOfRangeException:在位置 0 处没有任何行。]
System.Data.RBTree`
1 .GetNodeByIndex(Int32userIndex) + 148
System.Data.RBTree`
1 .get_Item(Int32index) + 18
System.Data.DataRowCollection.get_Item(Int32index)
+ 12
CheHang_CheHangPageFooter.Data_Binding()
in d:auto.dg.gd.cnCheHangCheHangPageFooter.ascx.cs: 34
CheHang_CheHangPageFooter.Page_Load(Objectsender,EventArgse)
in d:auto.dg.gd.cnCheHangCheHangPageFooter.ascx.cs: 29
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtrfp,Objecto,Objectt,EventArgse)
+ 13
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Objectsender,EventArgse)
+ 43
System.Web.UI.Control.OnLoad(EventArgse)
+ 80
System.Web.UI.Control.LoadRecursive()
+ 49
System.Web.UI.Control.LoadRecursive()
+ 132
System.Web.UI.Control.LoadRecursive()
+ 132
System.Web.UI.Page.ProcessRequestMain(BooleanincludeStagesBeforeAsyncPoint,BooleanincludeStagesAfterAsyncPoint)
+ 3750

版本信息:Microsoft .NET Framework 版本:2.0.50727.1378; ASP.NET 版本:2.0.50727.1378

检查经发现,原来“_memberKey”没有取得到值时,就去做数据绑定。

解决的办法,加上一个判断。

if (objSynopsis.GetSynopsisByMember(_memberKey).Rows.Count > 0 )
... {
DataRowdr
=objSynopsis.GetSynopsisByMember(_memberKey).Rows[0];
//othercode
}

<!-- [IndexOutOfRangeException]: 在位置 0 处没有任何行。 在 System.Data.RBTree`1.GetNodeByIndex(Int32 userIndex) 在 System.Data.RBTree`1.get_Item(Int32 index) 在 System.Data.DataRowCollection.get_Item(Int32 index) 在 CheHang_CheHangPageFooter.Data_Binding() 位置 d:\auto.dg.gd.cn\CheHang\CheHangPageFooter.ascx.cs:行号 34 在 CheHang_CheHangPageFooter.Page_Load(Object sender, EventArgs e) 位置 d:\auto.dg.gd.cn\CheHang\CheHangPageFooter.ascx.cs:行号 29 在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) 在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) 在 System.Web.UI.Control.OnLoad(EventArgs e) 在 System.Web.UI.Control.LoadRecursive() 在 System.Web.UI.Control.LoadRecursive() 在 System.Web.UI.Control.LoadRecursive() 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: 引发类型为“System.Web.HttpUnhandledException”的异常。 在 System.Web.UI.Page.HandleError(Exception e) 在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 在 System.Web.UI.Page.ProcessRequest() 在 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) 在 System.Web.UI.Page.ProcessRequest(HttpContext context) 在 ASP.chehang_default_aspx.ProcessRequest(HttpContext context) 位置 c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\auto.dg.gd.cn\f8964772\9a46bbe9\App_Web_29nql2ws.0.cs:行号 0 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -->

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值