Hi,
Is there any way to get a sum aggregate on a column when there is no DataField? We have a RadGrid where we need to fill some of the cells from ItemDataBound because our data item has in it a list of custom field values. The ItemDataBound method is here:
Now, some of the custom fields are numeric and we need to do aggregates on them. These fields are added to the grid this way:
The problem is that this code results in a "Exception has been thrown by the target of an invocation." error with an InnerException of "No matching constructor in type 'Decimal?'" When I comment the Aggregate line of the column definition, I get the expected values but the DataFormatString is not applied. This lead me to wonder if the issue is that I am setting the cell text in the ItemDataBound instead of giving a DataField, which I can't do. Any suggestions you have would be greatly appreciated.
Thanks,
Dan Norton
Is there any way to get a sum aggregate on a column when there is no DataField? We have a RadGrid where we need to fill some of the cells from ItemDataBound because our data item has in it a list of custom field values. The ItemDataBound method is here:
protected void WorkOrderGrid_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { GridDataItem item = e.Item as GridDataItem; WorkOrderDetailItem view = item.DataItem as WorkOrderDetailItem; List<CustomField> CustFlds = CustFields(); for (int j = 0; j < CustFlds.Count; j++) { item.Cells[FirstCustomFieldCell + j].Text = (string.IsNullOrEmpty(view.CustomFieldValues[j]) ? " " : view.CustomFieldValues[j]); } } } protected void AddCustomFieldColumnsToGrid(List<CustomField> customFields) { foreach (CustomField custFld in customFields) { if (custFld.CustomFieldType == "money") { GridNumericColumn col = new GridNumericColumn(); _reportGrid.Columns.Add(col); col.DataType = typeof(Decimal); col.DataFormatString = "$ {0:N}"; col.Aggregate = GridAggregateFunction.Sum; col.UniqueName = "cf" + custFld.Id.ToString(); col.HeaderText = custFld.Name; col.Display = false; } elseThanks,
Dan Norton