从Gridview删除记录! [英] Delete Record From Gridview!!
本文介绍了从Gridview删除记录!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了下面的代码从gridview中删除一条记录,但是在选择网格值的参数中出现错误对象引用未设置为对象的实例".请指教
i wrote the below code to delete a record from a gridview but i am getting error ''Object reference not set to an instance of an object.'' in the parameter for selecting grid value. please advice
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim Parram(6) As Object
Parram(0) = TxtTrx.Text.Trim
Parram(1) = GridView1.SelectedRow.Cells(1).Text
Parram(2) = GridView1.SelectedRow.Cells(2).Text
Parram(3) = GridView1.SelectedRow.Cells(3).Text
Parram(4) = GridView1.SelectedRow.Cells(3).Text
Parram(5) = GridView1.SelectedRow.Cells(4).Text
Dim Count As Integer = DataBase.ExecuteNonQuery("sp_DeletePTY_Rmt_D", Parram, "Aloha2GP")
If Count > 0 Then
LblError.Text = "(" & Count & ")" & "Record Deleted"
Else
LblError.Text = "(" & Count & ")" & " Record Deleted"
End If
end sub
推荐答案
对象引用未设置为对象的实例
当您尝试使用属性或调用对象的方法为null时,会发生此错误.更多详细信息:此处 [
Object reference not set to an instance of an object
This error happens when you try to use a property or call a method of an object that is null. More details: here[^]
A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line (Here: parameter for selecting grid value). Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.
这篇关于从Gridview删除记录!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文