DataGrid does not work correctly when selecting item to fill controls and refreshing...HELP???

A

Aaron Ackerman

I have been having just on going problems with my MS Datagrids. I have NO
idea what I am doing wrong.

What is esentially happening is that say I have three records in my Dataset.
I click on the third row to populate the textboxes below the grid that
correspond to the various columns in the grid. The textboxes fill. I edit
the data in one of the textboxes. As I lose focus I update the dataset and
refresh the grid.

Well the third row refreshes just fine. But I also fine that the first row
in my dataset also gets updates WITH ALL OF THE DATA FROM THE THIRD ROW??? I
have traced the dataset all through the update and cannot for the life of me
see where this happens. It seems to happen behind the scenes somewhere
through the databinding.

Anyway it is driving me nuts. Any ideas.
 
A

Aaron Ackerman

Private Sub txtConLastName_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtConLastName.LostFocus

Try ' Set up structured error handling.


vdsClientUI.ContactByID.Rows(dgContacts.CurrentRowIndex).Item("PersonLastNam
e") = Me.txtConLastName.Text
objClient.UpdateContactByID(Me.vdsClientUI, "ContactByID")
RefreshContactsGrid()
Catch ex As Exception ' Catch the error.
Me.blnErrorLogged = ErrorLog(ex.ToString) 'Log Error in DB
MsgBox(ex.ToString) 'Show friendly error message.
Me.Close() 'Close Form


Finally
' Beep after error processing.
End Try
End Sub


Private Sub RefreshContactsGrid()
Try ' Set up structured error handling.
Me.dgContacts.DataBindings.Clear()
vdsClientUI.Tables("ContactSelectAll").Clear()
vdsClientUI.Tables("ContactSelectAll").Dispose()

vdsClientUI.Tables("ContactByID").Clear()
vdsClientUI.Tables("ContactByID").Dispose()
'Me.dgContacts.Refresh()
vdsClientUI = objClient.selContacts(intClientID,
Me.strEmploymentConsultantSSN)
Me.dgContacts.SetDataBinding(vdsClientUI, "ContactSelectAll")
Me.dgContacts.DataBindings.Clear()

vdsClientUI = objClient.selContactByID(intClientID,
Me.strEmploymentConsultantSSN)


Catch ex As Exception ' Catch the error.
Me.blnErrorLogged = ErrorLog(ex.ToString) 'Log Error in DB
MsgBox(ex.ToString) 'Show friendly error message.
Me.Close() 'Close Form
'Application.ExitThread() 'Exit App
Finally
' Beep after error processing.
End Try

End Sub
 

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