错误:索引超出范围。必须是非负数且小于集合的大小。参数名称:index [英] Error:Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

查看:85
本文介绍了错误:索引超出范围。必须是非负数且小于集合的大小。参数名称:index的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从gridview中删除一行时出现此错误... plz帮我解决这个问题







When i delete a row from gridview im getting this error...plz help me to solve this



protected void grdClientDetails_RowDeleting(object sender, GridViewDeleteEventArgs e)
   {

       int int32Id = Convert.ToInt32(grdClientDetails.DataKeys[e.RowIndex].Value);

       ClsClientReg obj = new ClsClientReg();
       obj.DeleteClient(int32Id);

   }







谢谢



删除了SHOUTING - OriginalGriff [/ edit]




Thanks

[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

Quote:

ClsClientReg obj = new ClsClientReg();

obj.DeleteClient(int32Id);

ClsClientReg obj = new ClsClientReg();
obj.DeleteClient(int32Id);



如果第一行创建(因为它)看起来是一个空对象,第二行注定要失败。


If the first line creates (as it looks) an empty object, the second line is destined to fail.


Gridview datakeys集合似乎是空的。



设置DataKeyNames属性,然后访问它。
The Gridview datakeys collection seems to be empty.

Set the DataKeyNames property and then access it.


这篇关于错误:索引超出范围。必须是非负数且小于集合的大小。参数名称:index的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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