get-Specified参数异常超出了有效值的范围。 [英] Exception getting-Specified argument was out of the range of valid values.

查看:104
本文介绍了get-Specified参数异常超出了有效值的范围。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好伙计,

我正在使用Gridview行删除事件So.I收到此错误



ArgumentOutOfRangeException被捕获

指定的参数超出了有效值的范围。参数名称:索引



代码 -



<前lang =cs> protected void GridView1_RowDeleting( object sender,GridViewDeleteEventArgs e)
{
尝试
{

objBusinessUI.RouteID = Int32 .Parse(GridView1.DataKeys [e.RowIndex] .Value.ToString());
objBusinessUI.UpdatedBy = Admin;
objBusinessUI.UpdatedOn = DateTime.Now;
string strMsg = objDataUI.DeleteRoute(objBusinessUI);
if (strMsg == SUCCESS
{
lblErrorMSG.Text = 记录删除成功;
}
else
{
lblErrorMSG.Text = 删除记录时出现问题!请稍后再试;
}

}
catch (例外情况)
{
log.Error( System.Reflection.MethodBase.GetCurrentMethod()。ToString()+ ex.StackTrace);
}





在调试时,焦点出现在objBusinessUI.RouteID上,第一行...立即进入异常block..i不要了解什么是导致..还有一件事我想在这里注意..它级联..Means RouteId子节点和AreaID作为FK传递..因此导致这个问题。

Thakxxxxx提前

解决方案

我认为问题在于下面的代码 -

 GridView1 .DataKeys [e.RowIndex] .Value 





您是否为aspx文件中的网格指定了DataKeyNames的值?如果没有,请执行此操作。


Hi guyss,
I am working On Gridview Row Deleting event So.I getting this error

ArgumentOutOfRangeException was caught
Specified argument was out of the range of valid values. Parameter name: index

Code-

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {

                objBusinessUI.RouteID = Int32.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
                objBusinessUI.UpdatedBy = "Admin";
                objBusinessUI.UpdatedOn = DateTime.Now;
                string strMsg = objDataUI.DeleteRoute(objBusinessUI);
                if (strMsg == "SUCCESS")
                {
                    lblErrorMSG.Text = "Record deleted successfully";
                }
                else
                {
                    lblErrorMSG.Text = "There is problem in deleting record!Please try later";
                }

            }
            catch (Exception ex)
            {
              log.Error(System.Reflection.MethodBase.GetCurrentMethod().ToString() + ex.StackTrace);
            }



At the time of debugging focus comes on objBusinessUI.RouteID,first line..immediately its goes to the exception block..i dont uderstand whats is cause..and one more thing i am wanna note here..Its cascading ..Means RouteId child node and AreaID is passed as a FK..so its cause this problem .
Thakxxxxx in advance

解决方案

I think the problem lies in the below code-

GridView1.DataKeys[e.RowIndex].Value



Have you specified any value for DataKeyNames for the grid in the aspx file? If not, do so.


这篇关于get-Specified参数异常超出了有效值的范围。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆