S
Sajid
Hello,
I am trying to bind a DataTable to a Grid which will allow users to
Edit data and then submit the changes back to the Database. I want to
display values in the Grid satisfying a particular criteria like
follows:
Dim tbl as new DataTable
For Each row As DataRow In DataTableName.Rows
If (row.Item("ColumnName") Is System.DBNull.Value) Then
tbl.Rows.Add(row.ItemArray)
End If
Next
Grid.DataSource = tbl
But on the other hand I have created and Filled the DataTableName
dataTable as follows:
DataAdapter.Fill(DataTableName)
After the user has done changes on the Grid (e.g. Deleted few rows,
modifies few column values or added few rows), I want to Update the
Table and I issue the following command for that:
DataAdapter.Update(tbl)
Which gives me a problem that the Rows are not properly updated rather
multiple records are added for nothing and many other problems are
seen in the original table.
Also I cannot Update using the following:
DataAdapter.Update(DataTableName)
because I didn't bind the DataTableName DataTable to the Grid because
I only want to display records in the Grid satisfying certain
criteria.
Has anyone any idea how to make it work or modify my logic.
cheers
I am trying to bind a DataTable to a Grid which will allow users to
Edit data and then submit the changes back to the Database. I want to
display values in the Grid satisfying a particular criteria like
follows:
Dim tbl as new DataTable
For Each row As DataRow In DataTableName.Rows
If (row.Item("ColumnName") Is System.DBNull.Value) Then
tbl.Rows.Add(row.ItemArray)
End If
Next
Grid.DataSource = tbl
But on the other hand I have created and Filled the DataTableName
dataTable as follows:
DataAdapter.Fill(DataTableName)
After the user has done changes on the Grid (e.g. Deleted few rows,
modifies few column values or added few rows), I want to Update the
Table and I issue the following command for that:
DataAdapter.Update(tbl)
Which gives me a problem that the Rows are not properly updated rather
multiple records are added for nothing and many other problems are
seen in the original table.
Also I cannot Update using the following:
DataAdapter.Update(DataTableName)
because I didn't bind the DataTableName DataTable to the Grid because
I only want to display records in the Grid satisfying certain
criteria.
Has anyone any idea how to make it work or modify my logic.
cheers