Jason,
I'm not quite sure what you are trying to do, but you don't have to set a data source key when setting up a combobox to be populated. The data source key is set on the BO itself. The combobox simply references the appropriate BO. The BO knows what data source to use, the combo just needs to know what BO.
When you setup a combobox's list populations settings, you supply:
- BO that is used to fill combo
- A fill method to load BO with data. There are a number of fill methods available by default (e.g. FillByPrimaryKey, FillByParent, FillByParentPrimaryKey, etc.), but typically you need to write a fill method within the BO. In the help file, under Application Framework|Business Layer|Fill Methods - Populating a Business Object section, there are a number topics that address how to fill a BO, including writing Fill methods. An example fill method might look like (this is within the code of a BO):
//-- In a BO. In this case, this might be in a CustomersBO.
Public Sub FillForLookup()
Dim sqlBuilder As New StringBuilder(255)
With sqlBuilder
.AppendLine("Select cust_pk, cust_fname, cust_lname")
.AppendLine("From Customers")
End With
Using cmd As New SqlCommand
cmd.CommandText = sqlBuilder.ToString()
Me.FillDataTable(cmd)
End Using
End Sub
Notice that this fill method is specifically for use in lookup scenarios, like a combo. I'm not filling in all the data, just the data needed by the lookup (the combobox in this case). I'm assuming that the lookup will need to see the name and have the ID available for binding.
Once you have a Fill method in the BO, build the solution (so the new method can be picked up by the list population designer). Now, in the Method to Execute, you fill method should be listed (if not, you probably forgot to do the build).
The BO is setup with a datasourcekey. When the combobox is filled, it uses that key to make a connection to the data (via the DataSources collection that you setup in the SetDataSources of either AppMain.vb or Program.cs (depending on language)). The combobox then calls the set Method to Execute to load the BO, which then is used to load the combo. All of this happens behind the scenes based on how you setup the combobox to be filled.
I hope this help make some sense of what is happening. If you need more help, please don't hesitate to ask. You might want to include a more specific example too.