| | |
Difficulties with getchanges() method of datatable
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 18
Reputation:
Solved Threads: 0
Hi all,
I'm facing some difficulties with the getchanges method of a datatable...
In my program, I have a standalone datatable which I'm using as the datasource to a datagridview. When I make changes to the datagridview, and I use the getchanges(DataRowState.Modified) method, I get Nothing as the result, no matter what changes I made. I also tried using the table as bindingsource to the datagridview but this didn't help either. Can anybody please point me out what I'm doing wrong? Below is my code:
- usr is an object that contains a table named table
- dgv is a datagridview on my form
- the update sub is a member of usr which is called when a button on the form is clicked
Thanks in advance.
I'm facing some difficulties with the getchanges method of a datatable...
In my program, I have a standalone datatable which I'm using as the datasource to a datagridview. When I make changes to the datagridview, and I use the getchanges(DataRowState.Modified) method, I get Nothing as the result, no matter what changes I made. I also tried using the table as bindingsource to the datagridview but this didn't help either. Can anybody please point me out what I'm doing wrong? Below is my code:
- usr is an object that contains a table named table
- dgv is a datagridview on my form
- the update sub is a member of usr which is called when a button on the form is clicked
VB.NET Syntax (Toggle Plain Text)
BindingSource1.DataSource = usr.table BindingSource1.RaiseListChangedEvents = True dgv.DataSource = BindingSource1 public sub update() dim tmpdt as new datatable tmpdt = table.getchanges(DataRowState.Modified) end sub
Thanks in advance.
•
•
Join Date: Nov 2008
Posts: 63
Reputation:
Solved Threads: 10
This example code explains maybe :=)
MSDN says....
VB.NET Syntax (Toggle Plain Text)
Dim _DT As DataTable = Nothing Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load _DT = New DataTable _DT.BeginLoadData() For i As Integer = 0 To 5 Dim _Col As DataColumn = New DataColumn("", System.Type.GetType("System.String")) _DT.Columns.Add(_Col) _Col.Dispose() _Col = Nothing Next For i As Integer = 0 To 5 Dim _Row As DataRow = _DT.NewRow _Row.Item(0) = String.Format("Test {0}", i.ToString) _DT.Rows.Add(_Row) Next _DT.EndLoadData() _DT.AcceptChanges() Me.BindingSource1.DataSource = _DT Me.DataGridView1.DataSource = Me.BindingSource1 End Sub Private Sub BindingSource1_CurrentItemChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles BindingSource1.CurrentItemChanged Dim tmpTable As DataTable = _DT.GetChanges(System.Data.DataRowState.Modified) Me.DataGridView2.DataSource = tmpTable End Sub
MSDN says....
•
•
•
•
When you call AcceptChanges on the DataSet, any DataRow objects still in edit-mode end their edits successfully. The RowState property of each DataRow also changes; Added and Modified rows become Unchanged, and Deleted rows are removed.
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: how to add new row in datagridview on enter of any cell
- Next Thread: Problem with passing a variable
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google hardcopy html images input insert intel internet mobile monitor ms net networking objects open output panel passingparameters pdf picturebox picturebox1 port position print printing problem save searchbox searchvb.net select serial settings shutdown soap sqlserver survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet view visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





