IndexOutOfRangeException异常 在位置0处没有任何行
设计思路:
一个关于部门信息的主页面,该页面放置一个gridview,获取数据表中几个主要字段,单击第一个字段名称,链接到详细页面,该页面是一些label和textbox控件,接收数据表中的详细信息
在通用类(DepCommon)中定义几个const属性(关于数据表中的字段),创建一个方法BuildTable()返回一个table;
在详细页面的后台中,写入一个方法:
public void FillPage()
{
//获取上一页传过来的ID号
int depID = Convert.ToInt32(Request.Params[DepKey], 10);
//调用业务逻辑层的GetDepInfoByDepID方法
DepSystem dsystem=new DepSystem();
DataTable DepTable = dsystem.GetDepInfoByDepID(depID);
DataRow row = DepTable.Rows[0];
//将数据库中的数据分别填充在textbox控件中
this.txtBranch.Text = row[DepCommon.BranchID].ToString();
this.txtDepName.Text = row[DepCommon.DepName].ToString();
this.txtManager.Text = row[DepCommon.Manager].ToString();
this.txtTelOne.Text = row[DepCommon.Tel1].ToString();
this.txtTellTwo.Text = row[DepCommon.Tel2].ToString();
this.txtFax.Text = row[DepCommon.Fax].ToString();
this.txtProvince.Text = row[DepCommon.Province].ToString();
this.txtCity.Text = row[DepCommon.City].ToString();
this.txtArea.Text = row[DepCommon.District].ToString();
this.txtStreet.Text = row[DepCommon.Street].ToString();
this.txtPost.Text = row[DepCommon.PostCode].ToString();
}
运行时,出现IndexOutOfRangeException异常
在位置0处没有任何行
找了很久,都解决不了,很急,各位大虾走过路过,千万不要忽略过,帮小菜排忧解难一下,谢了
一个关于部门信息的主页面,该页面放置一个gridview,获取数据表中几个主要字段,单击第一个字段名称,链接到详细页面,该页面是一些label和textbox控件,接收数据表中的详细信息
在通用类(DepCommon)中定义几个const属性(关于数据表中的字段),创建一个方法BuildTable()返回一个table;
在详细页面的后台中,写入一个方法:
public void FillPage()
{
//获取上一页传过来的ID号
int depID = Convert.ToInt32(Request.Params[DepKey], 10);
//调用业务逻辑层的GetDepInfoByDepID方法
DepSystem dsystem=new DepSystem();
DataTable DepTable = dsystem.GetDepInfoByDepID(depID);
DataRow row = DepTable.Rows[0];
//将数据库中的数据分别填充在textbox控件中
this.txtBranch.Text = row[DepCommon.BranchID].ToString();
this.txtDepName.Text = row[DepCommon.DepName].ToString();
this.txtManager.Text = row[DepCommon.Manager].ToString();
this.txtTelOne.Text = row[DepCommon.Tel1].ToString();
this.txtTellTwo.Text = row[DepCommon.Tel2].ToString();
this.txtFax.Text = row[DepCommon.Fax].ToString();
this.txtProvince.Text = row[DepCommon.Province].ToString();
this.txtCity.Text = row[DepCommon.City].ToString();
this.txtArea.Text = row[DepCommon.District].ToString();
this.txtStreet.Text = row[DepCommon.Street].ToString();
this.txtPost.Text = row[DepCommon.PostCode].ToString();
}
运行时,出现IndexOutOfRangeException异常
在位置0处没有任何行
找了很久,都解决不了,很急,各位大虾走过路过,千万不要忽略过,帮小菜排忧解难一下,谢了
...全文
相关推荐
System.IndexOutOfRangeException(解决方案).md
System.IndexOutOfRangeException(解决方案).md
C#实验6 调试、测试和异常处理.
C#,调试,测试,异常处理.C#,调试,测试,异常处理.
09.你真的懂异常(Exception)吗.pdf
09.你真的懂异常(Exception)吗.pdf 09.你真的懂异常(Exception)吗.pdf 09.你真的懂异常(Exception)吗.pdf
C#异常处理知识汇总
主要介绍了C#异常处理的知识,文中讲解非常详细,配合代码帮助大家更好的理解,感兴趣的朋友可以参考下
C#异常处理中try和catch语句及finally语句的用法示例
主要介绍了C#异常处理中try和catch语句及finally语句的用法示例,finally语句的使用涉及到了C#的垃圾回收特性,需要的朋友可以参考下


