Groups | Blog | Home
all groups > asp.net datagrid control > june 2006 >

asp.net datagrid control : Sub in GridView delete error



David
6/23/2006 5:15:46 PM
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

Jan Hyde
6/27/2006 4:39:50 PM
"David" <dlchase@lifetimeinc.com>'s wild thoughts were
released on Fri, 23 Jun 2006 17:15:46 -0500 bearing the
following fruit:

[quoted text, click to view]

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

J


[quoted text, click to view]


Jan Hyde (VB MVP)

--
A pessimist's blood type is always b-negative. (Pun of the Day)
AddThis Social Bookmark Button