Hello,
The existing data table binded to a grid works When I enter the number of line items I need and click on a button that say make grid. The problem is when click on Add Rows the extra row does not appear. I think I am having a problem with the databind, because if I use, gvParts.DataBind(), the existing datagrid goes away.
Thank you in advance,
Existing Code used to create the data table to add records (WORKS)
**************************
**********
**********
**********
**
Protected Sub btnMkGrid_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEv
entArgs) Handles btnMkGrid.Click
Dim dt As New Data.DataTable
'Dim tblReceiving As Table
dt.Columns.Add(New Data.DataColumn("LineNO"))
For i As Integer = 1 To tbItems.Text
Dim dr As Data.DataRow
dr = dt.NewRow
dr("LineNO") = i
dt.Rows.Add(dr)
Next
'Bind the DataTable to the DataGrid
gvParts.DataSource = dt
gvParts.DataBind()
End Sub
**************************
**********
**********
******
Does Not Work
Protected Sub AddRow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddRow.Click
'Add the number of rows specified by "RowCount" to gvParts
If (IsNumeric(RowCount.Text))
Then
Dim i As Integer
For i = 1 To CInt(RowCount.Text)
'Adding a blank record to the dataset.
Dim dt As New Data.DataTable
dt.Columns.Add(New Data.DataColumn("LineNO"))
Dim dr As Data.DataRow
dr = dt.NewRow
dr("LineNO") = i
dt.Rows.Add(dr)
Next
End If
'Rebind the grid to show the newly added row(s).
'gvParts.DataBind()
'DataBind()
End Sub
Start Free Trial