|
-
Mar 17th, 2003, 07:55 PM
#1
Thread Starter
Lively Member
Data Bound Control Problems
I fixed one problem by binding controls to a dataset and created two more.
I an setting up a binding context like this:
Me.CustDataAdapter.Fill(DsCustomer1, "Customer")
bmb = Me.BindingContext(DsCustomer1, "customer")
Then I display the records full screen with one textbox for each field of data. I have command buttons for Next, Prev, Firsrt and Last which use the bindings like this:
Private Sub btnPrev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrev.Click
If bmb.Position > 0 Then
bmb.Position -= 1
End If
End Sub
Problem is, I cant update the dataset with new or changed records. After changes to the dataset I call the Update method of the CustDataAdapter, but nothing happens. If I test for dataset.HasChanges() it always comes back false.
For example, if you press the New Record button I clear the databound fields by doing this:
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
bmb.AddNew()
End Sub
Then fill in the blanks and press Save which does this:
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
CustDataAdapter.Update(DsCustomer1)
End Sub
There are no errors, but the new record is not saved. If I change a value on an existing record and do the Update, the change is not saved either. Calling the AcceptChanges method before the Update does no good either.
So what am I doing wrong?
-
Mar 17th, 2003, 10:08 PM
#2
Frenzied Member
-
Mar 18th, 2003, 06:00 PM
#3
Thread Starter
Lively Member
I agree. I left the bindings in for navigation buttons and coded the rest. Much better.
-
Mar 18th, 2003, 10:07 PM
#4
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|