iana -
per a previos your post of yours regarding the error "Cannot create column with the specified type name: GridCalculatedColumn":
"Hi Rob,
I followed your scenario and was able to replicate the issue. It seems that there is a problem with the ViewState of the calculated column when it is created at runtime. I forwarded the issue for further investigation and testing and hope it could be fixed soon.
As a workaround, I suggest that you set the EnableColumnsViewState property of the MasterTableView to false and create your columns on Page.Init or on each Page.Load.
Give it a try and let me know if this works for you."
i am also trying to dynamically create a radgrid with a calculated column and am getting the same error as rob was. has this been fixed?
my calculated column is in the markup, but i assign the DataFields and Expression property in the codebehind since the gridboundcolumns are dynamically generated. here is my code:
------------------------------
protected void InitPage()
{
ddlDestinations.FillWithEntity((new DestinationProxy()).GetAllDestinations(), true);
int n = ScrapTypes.Length;
string[] DataFields = new string[n];
string[] Expression = new string[n];
for (int i = 0; i < n; i++)
{
ScrapType ScrapType = ScrapTypes[i];
string ScrapTypeName = StripIt(ScrapType.Name);
string EditorId = "Editor" + ScrapTypeName;
GridEditableColumn col = new GridBoundColumn();
GridTemplateColumnEditor Editor = new GridTemplateColumnEditor();
rgCalendar.Columns.Add(col);
phEditors.Controls.Add(Editor);
//i build the GridCalculatedColumn properties here
DataFields[i] = ScrapTypeName;
Expression[i] = "{" + i.ToString() + "}";
((GridBoundColumn)col).DataField = ScrapTypeName;
((GridBoundColumn)col).Aggregate = GridAggregateFunction.Sum;
((GridBoundColumn)col).DataType = typeof(int);
col.UniqueName = ScrapTypeName;
col.HeaderText = ScrapType.Name;
col.ColumnEditorID = EditorId;
col.ItemStyle.Width = Unit.Pixel(100);
col.ItemStyle.Wrap = false;
Editor.ID = EditorId;
}
GridCalculatedColumn Calc = (GridCalculatedColumn)rgCalendar.Columns.FindByUniqueName("ItemTotal");
//here is where i assign those property values
Calc.Expression = string.Join("+", Expression);
Calc.DataFields = DataFields.ToArray();
rgCalendar.MasterTableView.SwapColumns("ItemTotal", StripIt(ScrapTypes[ScrapTypes.Length - 1].Name));
}
------------------------------
you previously recommended to another user that they disable viewstate, but this will affect being able to extract values from the grideditcolumns.
dynamic radgrid building has been an experience indeed. is there a resolution to this issue?