**Technology: **
MSSQL 2005
LLBLGEN Pro v2.6 - DataAdapter
C#
Tables and relations:
Customer - 1:m -> Statement
I have a DataGrid that is populated using a TypedList. I want to add a column that contains a combobox. because of the way the data is structured I have chosen to use the following to get the values for the combobox, but then I can't seem to bind it. I use the ApplyGridstyles method to set the grid up and then I set the datasource seperately somewhere else in the code. All is well until I try and populate the grid with the data.
To setup the grid I use:
grdReturnedMailCustomers.ReadOnly = false;
EntityField2 contactAddressField = new EntityField2("CustomerFullAddress",
new DbFunctionCall("[dbo].[cusif_GetFullAddressFromCrm]", new object[] { ContactAdrsFields.AddressId, ",", 1 }));
grid.AddNewColumn<DataGridViewTextBoxColumn>("CustomerID", CustomerFields.CustomerId).Visible = false;
grid.AddNewColumn<DataGridViewTextBoxColumn>("AccountNo", CustomerFields.AccountNo).Visible = true;
grid.AddNewColumn<DataGridViewTextBoxColumn>("CustomerFullName", ContactEntity.GetContactFullNameEntityField().SetFieldAlias("CustomerFullName")).AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
grid.AddNewColumn<DataGridViewTextBoxColumn>("CustomerFullAddress", contactAddressField).Visible = true;
grid.AddNewColumn<DataGridViewTextBoxColumn>("ReturnedReason", ReturnedMailFields.ReturnedMail).Visible = true;
grid.AddNewColumn<DataGridViewTextBoxColumn>("ReturnedDate", ReturnedMailItemFields.ReturnedDate, "d").Visible = true;
I have to use a db function to retrieve a concatenated address string (long story - works perfectly).
I then try the same method to retrieve a datatable for the statementdate in the following way:
//Get datatable using customerid
EntityField2 contactAddressField = new EntityField2("StatementId",
new DbFunctionCall("[dbo].[cusif_promisf_GetStatementsByCustomerId]", new object[] { CustomerFields.CustomerId }));
and try and add the column to the grid:
DataGridViewComboBoxColumn colStmtDate = DataGridViewComboBoxColumn();
colStmtDate.DataPropertyName = "StatementId";
colStmtDate.DataSource = statementField;
colStmtDate.DisplayMember = StatementFields.StmtDate.Name;
colStmtDate.ValueMember = StatementFields.StatementId.Name;
colStmtDate.ReadOnly = false;
grdReturnedMailCustomers.Columns.Add(colStmtDate);
By default I would like to select the combo index 1 (second value) for each row requried by business rules (to select the 2nd last statement).
What am i missing?! please let me know if you need anymore info...