Sub in GridView delete error

Discussion in 'ASP .Net Datagrid Control' started by David, Jun 23, 2006.

  1. David

    David Guest

    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
    David, Jun 23, 2006
    #1
    1. Advertising

  2. David

    Jan Hyde Guest

    "David" <>'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)

    --
    A pessimist's blood type is always b-negative. (Pun of the Day)
    Jan Hyde, Jun 27, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. THY
    Replies:
    1
    Views:
    388
    Steve C. Orr, MCSD
    Aug 19, 2003
  2. Kathy Burke
    Replies:
    3
    Views:
    382
    Kathy Burke
    Nov 24, 2003
  3. Tee
    Replies:
    2
    Views:
    795
  4. Ben
    Replies:
    2
    Views:
    859
  5. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    1,962
    Lawrence D'Oliveiro
    May 20, 2011
Loading...

Share This Page