We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

column binding question

I''m binding an custom Incomes collection to a GDBG. Incomes holds Income objects. My Income Class has public properties called EmployerName (String), and IncType (an IncomeType object). The IncomeType class has a property for IncomeTypeName (String). Can I bind the columns in the grid so they show IncomeObject.EmployerName and IncomeObject.IncomeType.IncomeTypeName? Here''s some (simplified) code showing how I''m trying it. The result is the EmployerName shows, but the IncType.IncomeTypeName doesn''t. I get the IncType column, but it''s just blank. Dim gbc As New GridBoundColumn gbc = New GridBoundColumn gbc.MappingName = "IncType.IncomeTypeName" gbc.HeaderText = "Source" dtgEmployerInfo.GridBoundColumns.Add(gbc) gbc = New GridBoundColumn gbc.MappingName = "EmployterName" gbc.HeaderText = "Employer" dtgEmployerInfo.GridBoundColumns.Add(gbc) dtgEmployterInfo.DataSource = m_Incomes ----- Lee Perkins

2 Replies

AD Administrator Syncfusion Team June 11, 2004 07:10 AM

We currently do not support accessing nested properties in this manner. You could use an event to swap out what is displayed. You could use either PrePareViewStyleInfo or model.QueryCellFormattedText to handle this. You would just set the MappingName to gbc.MappingName = "IncType". Then in PrepareViewStyleInfo if e.RowIndex > 0 and e.ColIndex points to this column, you can retrieve the IncType object from e.Style.CellValue, and then set e.Style.Text equal to the IncType.IncomeTypeName value.


LP Lee Perkins June 11, 2004 07:22 AM

Thanks for the suggestion. The solution I just finished testing and implementing was to override ToString() in the IncomeType class to return the IncomeType.IncomeTypeName, then just bind the "IncType" property to the column. Worked like a champ! :) ----- Lee Perkins

Loader.
Live Chat Icon For mobile
Up arrow icon