Hello. I have the following code to add a new row into a datatable and then bind it to a gridview. I need to add a new row anytime i click the Button2.
What do i need to change in the code so i can have multiple rows before i submit them to a database?
Private Sub BindGrid() Dim DT As New DataTable Dim Row As DataRow
DT.Columns.Add(New System.Data.DataColumn("Nome"))
DT.Columns.Add(New System.Data.DataColumn("Morada"))
Row = DT.NewRow
Row(0) = Nome.Text
Row(1) = Morada.Text
DT.Rows.Add(Row)
Dados.DataSource = DT
Dados.DataBind()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
BindGrid()
End Sub