null引用异常未处理

null引用异常未处理

本文介绍了如何解决“ null引用异常未处理“删除gridview行..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码....



受保护的子GridView1_RowDeleting(ByVal sender As Object,ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs)Handles GridView1.RowDeleting



Here is my code....

Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting

Dim vacid As Integer = Convert.ToInt32(DirectCast(GridView1.Rows(e.RowIndex).FindControl("txtVacid"), TextBox).Text)
      Dim myCommand As New SqlCommand
      Dim myConnection = New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
      Dim update As String
      Dim strsql As String
      myCommand.Connection = myConnection
      'vacid = CInt(GridView1.Rows(GridView1.SelectedRow.RowIndex).Cells(0).Text)
      update = "Delete  from  Pat_Vaccine_Details   where vaccine_id='" & vacid & "'"
      myCommand = New SqlCommand(update, myConnection)
      myConnection.Open()
      myCommand.ExecuteNonQuery()
      myCommand.Connection.Close()
      BindGrid()
  End Sub





在删除时,我收到此错误



空引用异常未处理



请帮助



while deleting , i got this error

"null reference exception was unhandled "

please help

推荐答案


这篇关于如何解决“ null引用异常未处理“删除gridview行..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:53