sivatx

sivatx

  • NA
  • 1
  • 0

DELETING THE VALUES IN DATAGRID

Jul 12 2004 2:45 AM
HERE I AM USING THE DATAGRID TO DELETE THE VALUES DIRECTLY. HERE IS THE CODE: If e.CommandName = "Delete" Then Dim strsql As String strsql = "delete from Task_Main where TaskId=" + CType(e.Item.FindControl("TaskId"), Label).Text cmd.Connection = Con cmd.CommandText = strsql If cmd.ExecuteNonQuery > 0 Then lblPname.Text = "You have Selected ProductID " + CType(e.Item.FindControl("TaskId"), Label).Text + " to be deleted" End If End If HERE IS THE ERROR MESSAGE : Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 255: If e.CommandName = "Delete" Then Line 256: Dim strsql As String THE FOLLOWING LINE SHOWES IN RED MARK Line 257: strsql = "delete from Task_Main where TaskId=" + CType(e.Item.FindControl("TaskId"), Label).Text Line 258: cmd.Connection = Con Line 259: cmd.CommandText = strsql