我得到“错误=索引超出范围".必须为非负数并且小于集合的大小.参数名称:“索引". [英] I get "error=Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index".
本文介绍了我得到“错误=索引超出范围".必须为非负数并且小于集合的大小.参数名称:“索引".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void gdvErrorlog_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
ErrorLogDetails delerror = new ErrorLogDetails();
GridViewRow Row = (GridViewRow)gdvErrorlog.Rows[e.RowIndex];
ErrorId = Convert.ToInt32(gdvErrorlog.DataKeys[e.RowIndex].Values["ErrorId"]);
EID = Convert.ToInt32(ErrorId.ToString());
delerror.UserName = username;
delerror.ErrorID = EID;
delerror.delerror();
gdvErrorlog.EditIndex = -1;
LoadErrorDetails();
}
catch(Exception ex)
{
}
}
推荐答案
您需要更详细地了解它-e.RowIndex似乎为负(表示没有这样的行)或引用已经删除的行.
在事件处理程序的第一行上放置一个断点,看看它何时被触发.值是负数吗?单个删除操作是否会触发多个命令?
You need to look at it in a bit more detail - it would appear that e.RowIndex is either negative (indicating no such row) or referencing an already deleted row.
Put a break point on the first line of the event handler, and see when it get fired. Is the value negative? Does it get fired more than one for a single delete operation?
请检查错误发生在哪一行.并检查e.RowIndex的值是什么.我认为它是-1.
plesase check on which line is error coming. and check that what is the value of e.RowIndex. i think it is -1.
首先,您需要检查数据是否在表中...有时是空表,它显示为上面的错误.
first you need to check whether that data is in table or not...sometimes for empty table, it displays like the above error.
这篇关于我得到“错误=索引超出范围".必须为非负数并且小于集合的大小.参数名称:“索引".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文