Hi,
Using VB2005, LLBLGen V2, Adapter, SQL Server 2K & WinForms. Seemed trivial for a while but now driving me nuts!
I have table Organisation which is related via its FK (OrgTypeID) to table OrganisationType.
My WinForm has a datagridview with 4 columns for editing table Organisation. One of the columns (OrgTypeID) is a combo box for selecting organisation name from table OrganisationType. The grid is bound via its BindingSource to table Organisation. The combo box is sourced from table OrganisationType which is populated with data.
Scenario 1 (Use an entity OrganisationType as source for combo)
When column Organisation.OrgTypeID is defined as NULL my form is fully functional. i.e The form will display without errors, even if the Organisation table is empty.
When column Organisation.OrgTypeID is defined as NOT NULL (my preference) and the Organisation table is empty, this causes an issue in in the classes OrganisationTypeEntity and OrganisationEntity and a 'System.ArgumentException: Value is not Valid' error then shows up in the grid. Similarly, an error is generated on a blank row when the table has data.
Question 1: As I would like to define OrgTypeID as NOT NULL, what do I have to do to get rid of the error ?
Scenario 2 (Use a TypedList as source for Combo)
I create a TypedList from table OrganisationType and drag it from the Toolbox for use on my form (via another BindingSource) as the data source for the combo box.
Problem: Unlike scenario 1, I can't get the combo box to display when I run and open the form. Is there anything wrong with my code for filling the TypedList?
Function GetSortedOrganisationTypeList() As OrganisationTypeListTypedList
Dim adapter As New DataAccessAdapter
Try
Dim orgTypeList As New OrganisationTypeListTypedList
Dim sorter As ISortExpression = New SortExpression()
sorter.Add(New SortClause(OrganisationTypeFields.OrgTypeName, Nothing, SortOperator.Ascending))
adapter.FetchTypedList(orgTypeList.GetFieldsInfo(), orgTypeList, Nothing, 0, sorter, True)
Return orgTypeList
Finally
adapter.Dispose()
End Try
End Function
Thanks