Professional Documents
Culture Documents
Datagridview Update Row
Datagridview Update Row
net: how to update all data from datagridview to Sql server database at once in
VB.net - YouTube DATAGRIDVIEW UPDATE ROW
Imports System.Data.DataTable
table.Columns.Add("Id", Type.GetType("System.Int32"))
table.Columns.Add("First Name", Type.GetType("System.String"))
table.Columns.Add("Last Name", Type.GetType("System.String"))
table.Columns.Add("Age", Type.GetType("System.Int32"))
DataGridView1.DataSource = table
End Sub
index = e.RowIndex
selectedRow = DataGridView1.Rows(index)
TextBoxID.Text = selectedRow.Cells(0).Value.ToString()
TextBoxFN.Text = selectedRow.Cells(1).Value.ToString()
TextBoxLN.Text = selectedRow.Cells(2).Value.ToString()
TextBoxAGE.Text = selectedRow.Cells(3).Value.ToString()
End Sub
Private Sub btnUpdate_Click(sender As Object, e As EventArgs)
Handles btnUpdate.Click
Dim newDataRow As DataGridViewRow
newDataRow = DataGridView1.Rows(index)
newDataRow.Cells(0).Value = TextBoxID.Text
newDataRow.Cells(1).Value = TextBoxFN.Text
newDataRow.Cells(2).Value = TextBoxLN.Text
newDataRow.Cells(3).Value = TextBoxAGE.Text
End Sub
End Class