索引超出了 Gridview 中数组错误的界限
Index was outside the bounds of the array error in Gridview
我知道这个问题在这个网站上已经回答了很多次,但有点不同。请看我的issue
我想通过以下代码从 gridview
中 删除 行:-
protected void GrdQualification_DeleteCommand(object sender, Obout.Grid.GridRecordEventArgs e)
{
if (Session["DtFilldata"] != null)
{
DtFilldata = (DataTable)Session["DtFilldata"];
}
else
{
BindDatatable();
}
DataRow[] advRow = DtFilldata.Select("Q_SRNO=" + Convert.ToString(e.Record["Q_SRNO"]));
DtFilldata.Rows.Remove(advRow[0]);
AddToViewState();
}
但我收到错误消息
Index was outside the bounds of the array
我检查了该站点的链接,但对我没有帮助。
有什么不对的地方请指出
实际上,在调试时我发现 AddToViewState()
函数给我带来了问题。
因为它再次进行函数调用,所以它会 Out of Index
。所以我删除了它,它按要求工作了。
我知道这个问题在这个网站上已经回答了很多次,但有点不同。请看我的issue
我想通过以下代码从 gridview
中 删除 行:-
protected void GrdQualification_DeleteCommand(object sender, Obout.Grid.GridRecordEventArgs e)
{
if (Session["DtFilldata"] != null)
{
DtFilldata = (DataTable)Session["DtFilldata"];
}
else
{
BindDatatable();
}
DataRow[] advRow = DtFilldata.Select("Q_SRNO=" + Convert.ToString(e.Record["Q_SRNO"]));
DtFilldata.Rows.Remove(advRow[0]);
AddToViewState();
}
但我收到错误消息
Index was outside the bounds of the array
我检查了该站点的链接,但对我没有帮助。
有什么不对的地方请指出
实际上,在调试时我发现 AddToViewState()
函数给我带来了问题。
因为它再次进行函数调用,所以它会 Out of Index
。所以我删除了它,它按要求工作了。