Binding DataGrid and Textbox

C

Compunick

On my winform I have a both a Datagrid control and a Textbox control bound
to the same dataset. I used the designtime properties window to bind both
controls to the dataset. Here's my dillema:

When I update a field using the Datagrid, the save routine works.
When I update a field using the Textbox, the save routine does NOT work.

I need to be able to select my current record using the Datagid and then do
the record updates using Textboxes. Can anyone plese HELP!

Here is my save routine:
Me.cnGTS.Open()

Dim UpdatedRows As DataSet

Dim InsertedRows As DataSet

Dim DeletedRows As DataSet

UpdatedRows = Me.DsPERSONNEL1.GetChanges(DataRowState.Modified)

InsertedRows = Me.DsPERSONNEL1.GetChanges(DataRowState.Added)

DeletedRows = Me.DsPERSONNEL1.GetChanges(DataRowState.Deleted)

Try

If Not UpdatedRows Is Nothing Then Me.daPersonnel.Update(UpdatedRows)

If Not InsertedRows Is Nothing Then Me.daPersonnel.Update(InsertedRows)

If Not DeletedRows Is Nothing Then Me.daPersonnel.Update(DeletedRows)

Me.DsPERSONNEL1.AcceptChanges()

Catch eUpdate As System.Exception

MsgBox("Caught exception: " & eUpdate.Message)

End Try

Me.cnGTS.Close()



(e-mail address removed)
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

You should probably force the CurrencyManager serving the grid and the
textbox to propagate the changed value back to the datasource. You can do so
by calling EndCurrentEdit() on the CurrencyManager when a kind of "Save"
button is clicked. On the other hand, this process should be performed
automatically when the focus is switched to another control.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top