DataCells not binding using custom DataTable

Oct 24, 2008 at 11:33 AM
I have a configurable set of columns for my datagrid, each row has an underlying object with a collection of "Property" objects each containing Name and DisplayValue for simplicity. The configuration deems which columns should be displayed and therefore which "Property" objects need to be retrieved from the collection. A property has a DisplayValue property used to get and set. I'm building a datatable based on the configuration, the first thing I do is create a datacolumn for each column in the configuration:-

 

Dim lobjDataColumn As New DataColumn(lobjColItem.Value.InternalName, Type.GetType("System.Object"))
Me.Columns.Add(lobjDataColumn)

 

Then I enumerate the data collection creating a new DataRow for each object and then adding the column data based on the column configuration:-

 

Dim lobjNewRow As DataRow = Me.NewRow
Dim lobjColItem As Generic.KeyValuePair(Of Integer, ColumnHeaderGrid)
For Each lobjColItem In pobjColHdrs
    
Dim lobjAttribute As Client.Schema.Model.Property = Nothing
    lobjAttribute = CType(pobjItem.Attributes(lobjColItem.Value.InternalName), Client.Schema.Model.Property)
    lobjNewRow.Item(lobjColItem.Value.InternalName) = lobjAttribute
Next
Me.Rows.Add(lobjNewRow)

 

I then set the ItemsSource property on my grid which has AutoGenerateColumns=True

 

Me.FilterDataGrid.ItemsSource = lobjTable.DefaultView

 

Everything is displaying fine, sorting, grouping and filtering are excellent. What is not working is the property binding, I was hoping that when i edit a cell in the grid it would call the set property on the property.DisplayValue - unfortunately not. The table row knows the value has changed. I've spent hours reading and trying things but no luck.

Any help most appreciated...

Thanks
Coordinator
Nov 4, 2008 at 1:37 AM
So editing works but doesn't call DisplayValue or editing doesn't work b/c it's not calling DisplayValue?
Nov 4, 2008 at 12:01 PM
Hi, Editing works but doesn't call DisplayValue property to set the value in the object sat behind the datatable. I've moved on since I posted this and although I would still like to understand why, its not holding me up anymore. I'll knock up a sample which highlights the problem.