Sub in GridView delete error

D

David

I am getting "Object reference not set to an instance of an object."
when I try to set the value of a string variable in a OnDelete method of sql
command subroutine. Can anyone help with the syntax? Below is code:

Sub On_Subfile_Deleting(ByVal source As Object, ByVal e As
SqlDataSourceCommandEventArgs)

'Set value of new Subfile text from cell

'Subfile text is contained in the 3rd column (index 2).

Dim strsubfile As String = SubfilesGridView.SelectedRow.Cells(2).ToString()


'Set value of new SeqNo from cell

'SeqNo is contained in the 2nd column (index 1).

Dim strseqno As String = SubfilesGridView.SelectedRow.Cells(1).ToString()


'Run function in DBClass module to delete network subfile folder

LblMsg.Text = DBClass.DeleteSubfolders(strseqno, strsubfile,
CLng(txtFileNumber.Text))

LblMsg.Visible = True


End Sub 'On_Subfile_Updating

Thank you.

David
 
J

Jan Hyde

"David" <[email protected]>'s wild thoughts were
released on Fri, 23 Jun 2006 17:15:46 -0500 bearing the
following fruit:
I am getting "Object reference not set to an instance of an object."
when I try to set the value of a string variable in a OnDelete method of sql
command subroutine. Can anyone help with the syntax? Below is code:

You'll find slectedrow isn't set on a delete, if you want to
know which row invoked the delete use e.RowIndex

J

Sub On_Subfile_Deleting(ByVal source As Object, ByVal e As
SqlDataSourceCommandEventArgs)

'Set value of new Subfile text from cell

'Subfile text is contained in the 3rd column (index 2).

Dim strsubfile As String = SubfilesGridView.SelectedRow.Cells(2).ToString()


'Set value of new SeqNo from cell

'SeqNo is contained in the 2nd column (index 1).

Dim strseqno As String = SubfilesGridView.SelectedRow.Cells(1).ToString()


'Run function in DBClass module to delete network subfile folder

LblMsg.Text = DBClass.DeleteSubfolders(strseqno, strsubfile,
CLng(txtFileNumber.Text))

LblMsg.Visible = True


End Sub 'On_Subfile_Updating

Thank you.

David


Jan Hyde (VB MVP)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top