gridview在检查数据冲突时给出错误,如果每件事情都好,它应该删除并显示有关删除操作的标签 [英] gridview gives me error when m checking data conflict and if every thing is good it should delete and display a label about delete operation

查看:57
本文介绍了gridview在检查数据冲突时给出错误,如果每件事情都好,它应该删除并显示有关删除操作的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gridview给出了错误,如果每件事情都好,它应该删除并显示关于删除操作的标签

但是在正常的删除操作中它会给出错误。我不知道它是什么。



指数超出范围。必须是非负数且小于集合的大小。

参数名称:index

i已将此代码从c#转换为来自developerfusion.com的vb帮助我发现错误







gridview gives me error when m checking data conflict and if every thing is good it should delete and display a label about delete operation
but on normal delete operation it give error . I dont knw what it is.

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
i have converted this code code from c# to vb from developerfusion.com help me to find error



Protected Sub GridView1_RowDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeletedEventArgs) Handles GridView1.RowDeleted
        lblmessage.Visible = True
        If (e.AffectedRows > 0) Then
            lblmessage.Text = "Company row with companyID = """ + e.Keys(0).ToString() + """ is successfully deleted "
            lblmessage.ForeColor = System.Drawing.Color.Navy
        Else
            lblmessage.Text = "Company row with companyID = """ + e.Keys(0).ToString() + """ is not deleted due to data conflict"
            lblmessage.ForeColor = System.Drawing.Color.Red
        End If
    End Sub

解决方案

简单。根据错误消息, e.Keys(0)不存在。你有一个没有元素的数组。
Simple. According to the error message, e.Keys(0) doesn't exist. You've got an array with no elements in it.


这篇关于gridview在检查数据冲突时给出错误,如果每件事情都好,它应该删除并显示有关删除操作的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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