Windows Mobile : How to bind dropdown's selectedvalue to a column in table A and the list data to a

Posted by Rob on Stack Overflow See other posts from Stack Overflow or by Rob
Published on 2009-08-10T08:43:21Z Indexed on 2010/04/27 3:33 UTC
Read the original article Hit count: 322

Hi,

I am trying to learn the basics of Windows Mobile development against SQL CE and have come across a basic problem.

I have two tables. One called Customers that stores customer info and has an identity column called ID as the primary key. The other table is called Orders which has a column called CustomerID (the FK constraint is present).

I have added a DataSet to the project that contains both tables and have autogenerated the edit/view forms. This has produced a text control for the CustomerID column in the Order table for the new/edit form and I deleted it and replaced it with a dropdown list. Then, using the 'Advanced' databinding options (in Properties) I set the datasource of the list to the Customers table setting the value to the ID field and the text to the CustomerName field. I then set the SelectedValue of the list box to the CustomerID field of the Orders dataset. So far so good. When I run the app in the emulator and view the 'New' form for Orders the Customer dropdown is indeed populated with a list of customer names and I can select one and happily create a new order successfully. This is confirmed when I see the order appear in the Orders Grid form.

However, when I then click on the order in the grid and then select 'Edit' the order loads but the dropdown always shows the first customer in the list and doesn't seem to bind the SelectedValue to the Orders dataset CustomerID field. Now I am an ASP.NET guy and normally hand craft the DAL and it's binding to the UI so I'm not entirely sure where to look to investigate what is going wrong here as this is all generated code. I am sure it is something very trivial but any pointers would be appreciated.

My gut feeling is that the SelectedValue and the Customers.CustomerID values do not match for some reason?

Many thanks,

Rob.

© Stack Overflow or respective owner

Related posts about sql-server-ce

Related posts about windows-mobile