I am adding columns to a grid programmatically as the number of columns can vary. Additionally I want to sum the column values in the column footer. The following code is used to achieve this;
This creates columns with headings such as "2014", "2015", etc that are bound to "Period01", "Period02", etc.
The following code is then used to to obtain and bind the data to the grid;
The EquipList is populated correctly with a nullable Double data type being returned for "Period01", "Period02", etc however I get the error "No generic method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments." when I attempt to bind the EquipList object to the ItemsSource.
Could the nullable data type be causing the problem?
Private Sub AddContractYearColumns() Dim sPeriod As String = String.Empty Dim iIndex As Integer = 0 Try Dim Years = From Yrs In gdcRAD.vw_ProjectYears Select Yrs.Year For Each Yr As String In Years If Yr.ToInteger >= Year(Date.Today) Then iIndex += 1 sPeriod = "Period" & iIndex.ToString("00") Dim column As New GridViewDataColumn() With column .Header = Yr .UniqueName = Yr .DataMemberBinding = New Binding(sPeriod) .DataFormatString = "0.00" .TextAlignment = TextAlignment.Right End With gvContractYrs.Columns.Add(column) Dim f As New Telerik.Windows.Data.SumFunction f.SourceField = sPeriod gvContractYrs.Columns(Yr).AggregateFunctions.Add(f) End If Next Catch ex As Exception Throw New RadException("Add Contract Year Columns", ex.Message, ex.InnerException) End TryEnd SubThis creates columns with headings such as "2014", "2015", etc that are bound to "Period01", "Period02", etc.
The following code is then used to to obtain and bind the data to the grid;
Private Sub DisplayAvailableEquipYrs() Try Dim EquipList = (From Equipment In gdcRAD.usp_YearsAvailable(Date.Today, False, False) Select Equipment).ToList gvContractYrs.ItemsSource = EquipList Catch ex As Exception Throw New RadException("Display Available Equipment Years", ex.Message, ex.InnerException) End TryEnd SubThe EquipList is populated correctly with a nullable Double data type being returned for "Period01", "Period02", etc however I get the error "No generic method 'Sum' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments." when I attempt to bind the EquipList object to the ItemsSource.
Could the nullable data type be causing the problem?