detecting delete on row in datagridview and updating dataset

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 114
Reputation: ninjaimp is an unknown quantity at this point 
Solved Threads: 6
ninjaimp ninjaimp is offline Offline
Junior Poster

detecting delete on row in datagridview and updating dataset

 
0
  #1
Nov 21st, 2008
i have a datagrid which show values in a dataset.

I can add new values fine with the below code, but when i delete one of the rows (highlighting a row and using the delete key) i get the error:

'Update requires a valid DeleteCommand when passed DataRow collection with deleted rows.'

this is flaggin on the bolded line below

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim drNew As System.Data.DataRow

        drNew = Me.ISurfDataSet.Urls.NewRow
        drNew.Item("URLLink") = urlTextBox.Text
        Me.ISurfDataSet.Urls.Rows.Add(drNew)

        Changes = True 'set the flag to show that changes have been made

    End Sub

    Sub AddData() ' add the new urls to the database



        Me.Validate()
        Me.UrlsBindingSource.EndEdit()
        Me.UrlsTableAdapter.Update(Me.ISurfDataSet.Urls)

        MsgBox("All new data added successfully!")

        Changes = False ' all canges have been saved so the form can close

        Me.Close()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Call AddData() ' call the function to add the new urls to the database

    End Sub

    Private Sub UrlsDataGridView_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs) Handles UrlsDataGridView.UserDeletedRow
        Me.Validate()
        Me.UrlsBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ISurfDataSet)
    End Sub


any help is appreciated
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC