i want to display the inserted row to my datagridview. how can i accomplish this?

Imports System.Data.SqlClient

Public Class Model
    Dim sqldata As SqlDataAdapter
    Dim modeldata As New DataSet
    Dim sqlquery As String
    Dim conn As New SqlConnection

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim NewPlaneModel As New NewModel
        Dim Result As DialogResult
        Result = NewPlaneModel.ShowDialog()
        If Result = Windows.Forms.DialogResult.OK Then
           'some codes to update my datagridview. ?????
        End If
    End Sub

    Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
        Dim EditPlaneModel As New EditModel
        EditPlaneModel.ShowDialog()
    End Sub

    Private Sub Model_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            conn = GetConnect()
            conn.Open()
            sqlquery = "SELECT Manufacturer, Model, NRows, NCols FROM PlaneTypes ORDER BY Id ASC"
            sqldata = New SqlDataAdapter(sqlquery, conn)
            sqldata.Fill(modeldata)
            gridPlaneModel.DataSource = modeldata.Tables(0)
            gridPlaneModel.AutoResizeColumn(0)
            gridPlaneModel.AutoResizeColumn(1)
            gridPlaneModel.AutoResizeColumn(2)
            gridPlaneModel.AutoResizeColumn(3)
            gridPlaneModel.AllowUserToResizeColumns = False
            gridPlaneModel.AllowUserToResizeRows = False
            gridPlaneModel.AllowUserToAddRows = False
        Catch ex As Exception

        Finally
            conn.Close()
        End Try
    End Sub
End Class

NewPlaneModel dialog inserts a new record to the database.

what i want to happen is when i click the OK button in the NewPlaneModel dialog, the new record will appear in the gridPlaneModel datagridview.

how can i achieve this?

>i want to display the inserted row to my datagridview. how can i accomplish this?

You might want to show all rows having Inserted RowState. Use daaViewObject.RowStateFilter = DataViewRowState.Added

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.