I have bind the DataGridview with DB. To add the data from textboxes to DataGrid, I use the foll. code-

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            Dim row0 As String() = {TextBox1.Text, TextBox2.Text, TextBox3.Text}
            DataGridView1.Rows.Add(row0)
            row0 = Nothing
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Error is coming
Rows cannot be programmatically added to the DataGridView's rows collection when the control is data-bound

there is no any way to add data to the Gridview if we bound it to the Database.

The DataGridView control is simply a means of displaying data from an underlying datasource such as a DataSet/DataTable/Array etc.... You do not want to add rows directly to the DataGridView, you want to add rows to the underlying datasource. Such as if you have a datatable attached, it is the datatable you want to add a row too.

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.