System.IndexOutOfRangeException: 索引在陣列的界限之外

Cwx_Rlin 2007-07-03 02:57:12
菜鳥孤單求援~~~~~~~~~~~
...全文
1585 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cwx_Rlin 2007-07-03
  • 打赏
  • 举报
回复
世態炎良.唉~~~CSDN~~我看你是讓我徹徹底底的心良了.
Cwx_Rlin 2007-07-03
  • 打赏
  • 举报
回复
我在GridView中,我在點刪除和編輯的時候出現這個錯誤.誰叫幫俺看看有啥問題?
編輯更新代碼:
protected void MainGrid_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
DataTable dt = access.SelectData();

try
{
int rowIndex = (int)this.MainGrid.PageIndex * (int)this.MainGrid.PageSize + (int)e.RowIndex;
DataRow[] rows = dt.Select("TSYS_NO = '" + this.MainGrid.Rows[rowIndex].Cells[2].Text + "'");
DataRow row = rows[0];

if (row != null)
{
row["TSYS_NO"] = ((TextBox)this.MainGrid.Rows[rowIndex].Cells[2].FindControl("TSYS_NO")).Text;
row["TSYS_NAME"] = ((TextBox)this.MainGrid.Rows[rowIndex].Cells[3].FindControl("TSYS_NAME")).Text;
}
access.UpdateData(dt);
this.MainGrid.EditIndex = -1;
BindGrid();
}
catch (Exception ex)
{
throw ex;
}
}
刪除代碼:

protected void MainGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
DataTable dt = access.SelectData();

if (access.IsTsysNoUsed(this.TSYS_NO.Text))
{
this.Msg.AlertMessage = "該資料被使用,無法刪除!";
return;
}

try
{
DataRow[] rows = dt.Select("TSYS_NO = '" + this.MainGrid.Rows[e.RowIndex].Cells[2].Text + "'");

rows[0].Delete();
access.UpdateData(dt);
BindGrid();
}
catch (Exception ex)
{
throw ex;
}

}

小弟感激不盡~~~~~~以身相許了^_^ !
Cwx_Rlin 2007-07-03
  • 打赏
  • 举报
回复
沒人幫助么??唉~~~~~~~~ 這么簡單的我都不會,真是比豬還要笨~~~~失落中

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧