Glenn,
Did you solve this problem? I have just run into the same thing and can't fugure why, it was working, or so I thought!
I have now created a clean test project to try and see what is wrong. It uses a simple table in Nwind - sql create below.
Using:
EntitySpaces Version # 2007.0.0304.0
MyGeneration Version # 1.2.0.2
I have also used 1.5.3 and see no difference.
If the table contains no rows the first row added will be blank. Adding more rows works just fine. The problem seems to be that the current row on the bindingsource is at -1 after the addNew and not at position 0 as it seems to expect. Why might the binding source not reposition to the added row after the AddNew?
In the interest of simplicity, I have no binding navigator, just a few buttons.
Declan
Code:
1 Imports EntitySpaces.Core
2 Imports EntitySpaces.Interfaces
3
4 Imports ES_NorthWind.BusinessObjects
5
6 Public Class DataBindingTest
7
8
9 Dim collNewCustomers As NewCustomersCollection = New NewCustomersCollection
10
11 Private Sub DataBindingTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
12
13 collNewCustomers.LoadAll()
14 Me.NewCustomersCollectionBindingSource.DataSource = collNewCustomers
15
16 End Sub
17
18 Private Sub addNewItem()
19 NewCustomersCollectionBindingSource.AddNew()
20 End Sub
21
22 Private Sub saveItem()
23
24 ShowPosition()
25
26 NewCustomersCollectionBindingSource.EndEdit()
27 collNewCustomers.Save()
28 End Sub
29
30 Private Sub deleteItem()
31
32 ShowPosition()
33
34 NewCustomersCollectionBindingSource.RemoveCurrent()
35 collNewCustomers.Save()
36 End Sub
37
38 Private Sub ShowPosition()
39 Console.WriteLine("Count {0}; Position {1}", NewCustomersCollectionBindingSource.CurrencyManager.Count, _
40 NewCustomersCollectionBindingSource.CurrencyManager.Position)
41
42 End Sub
43
44 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
45 Me.NewCustomersCollectionBindingSource.MoveFirst()
46 End Sub
47
48 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
49 Me.NewCustomersCollectionBindingSource.MovePrevious()
50 End Sub
51
52 Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
53 Me.NewCustomersCollectionBindingSource.MoveNext()
54 End Sub
55
56 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
57 Me.NewCustomersCollectionBindingSource.MoveLast()
58 End Sub
59
60 Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
61 addNewItem()
62 End Sub
63
64 Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
65 deleteItem()
66 End Sub
67
68 Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
69 saveItem()
70 End Sub
71 End Class
Code:
1 USE [NorthWind]
2 GO
3 /****** Object: Table [dbo].[NewCustomers] Script Date: 03/08/2007 16:52:52 ******/
4 SET ANSI_NULLS ON
5 GO
6 SET QUOTED_IDENTIFIER ON
7 GO
8 CREATE TABLE [dbo].[NewCustomers](
9 [CustomerID] [int] IDENTITY(1,1) NOT NULL,
10 [CompanyName] [nvarchar](40) COLLATE Latin1_General_CI_AI NULL,
11 [ContactName] [nvarchar](30) COLLATE Latin1_General_CI_AI NULL,
12 CONSTRAINT [PK_NewCustomers] PRIMARY KEY CLUSTERED
13 (
14 [CustomerID] ASC
15 )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
16 ) ON [PRIMARY]