Group: Forum Members
Posts: 9,
Visits: 17
|
I'm having pretty much the same problem, but I'm afraid I didn't really follow your answer. I've reviewed lots of forum posts (and even read the help - gasp!) on this issue but I cannot find my problem.
I am working up a basic Customer maintenance form with customer details and address. These come from the Customer_Master and Customer_Address tables. These tables also contain foreign keys to rows in a lookup table called Std_Codes, for information like title (Mr, Mrs etc) and street type (St, Rd, Ave, etc). The different standard codes are grouped together by a standard code type ID, which we can use to retrieve all titles or all street types etc.
I have a Customer BO, which has a "TitleCode" property, and a CustomerAddress BO with a "StreetType" property. As discussed above the title literal is not stored directly in the customer table but comes from a list of title codes stored in the Std_Codes table - hence I also have a StandardCodes BO, which has a method to populate by the standard code type (Title Type, Street Type, etc). The StandardCodes BO has "StdCodesID" and "Description" properties - the StdCodesID is the value stored in the customer record for title code.
On the form I have Title and Street Type combo boxes. The combos need to populate themselves from the StandardCodes BO (two instances of which exist on the form and are called titleTypes1 and streetTypes1) but the selected value needs to set its ID back into the TitleCode property of the customer and the StreetType property of the address respectively.
So far so good... so I have bound the Title combo to the Customer BO, and the StreetType combo to the CustomerAddress BO, since that is where the selected values are read from and written to, and they are populated at form load from their respective StandardCodes instances. As far as I can tell I have followed the directions in the help, but the combo boxes are disabled at run-time. Following the property settings for the Title combo we have:
BindingField: TitleCode
BusinessObject: customer1
DisplayMember: Description
PopulateOnFormLoad: FormLoad
PopulationDataSourceSettings: StandardCode.FillByCodeType(string)
PopulationType: BusinessObject
List Population settings:
Business Object Type: StandardCode
Method to execute: FillByCodeType(string)
Display member: Description
Value member: StdCodesID
In the form code I have the following event handler:
private void cboTitle_ListPopulating(ListPopulatingEventArgs e)
{
e.Parameters[0].Value = "TITTY";
}
where the parameter value identifies the standard code type (apologies for the unfortunate abbreviation of Title Type!).
I hope this makes some kind of sense. I'm guessing the problem is going to relate to the fact that I am populating the combo from a different BO than the one it is bound to... but I can't figure out the solution. Selecting foreign keys from lookup tables, to be stored in the main table, is after all a very common sort of operation so I figure you have to support it.
To try to diagnose my problem I added another combo box to the form, and just bound it to the titleTypes1 BO (with the other settings the same) but this gave me a combo that was not disabled, but which appeared to have lots of blank entries in it that were not selectable.
It shouldn't be this hard... I'm obviously missing something crucial.
Perplexed,
Andrew.
|