IndexOutOfRangeException异常 在位置0处没有任何行
泼墨有点咸 2010-08-12 12:02:26 设计思路:
一个关于部门信息的主页面,该页面放置一个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处没有任何行
找了很久,都解决不了,很急,各位大虾走过路过,千万不要忽略过,帮小菜排忧解难一下,谢了