Basically my problem is that I try to 23 columns groups for a grid view and it works and I add just 1 column grid view group and i have
"An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.WinControls.GridView.dll
Additional information: Object reference not set to an instance of an object." error. Is there any way to have in a grid view 24 columns groups or more?
Is there any maximum number of GridViewColumnGroup that you can assign to a RadGrid? I can add 23 groups (each contain subgroup) but when I add the 24 group I get :
"An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.WinControls.GridView.dll
Additional information: Object reference not set to an instance of an object."
I use the DLL from 2014. Any advice is helpful. I thank you much for your help and time.
My function is
[QOUTE]ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
// Group Header
view.ColumnGroups.Add(new GridViewColumnGroup(""));
view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["pk_pr_cip"]);
view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Bifa"]);
view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Cip"]);
view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Program"]);
view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Reper"]);
view.ColumnGroups[0].Rows[0].Columns.Add(dg_validare_antecalcul.Columns["Denumire Reper"]);
view.ColumnGroups[0].ShowHeader = false;
// CSTA
GridViewColumnGroup oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTA";
GridViewColumnGroup oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Pret de vanzare unitar";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTA_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTA_cip"]);
dg_validare_antecalcul.Columns["CSTA_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTA_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// cost complet
oGroup = new GridViewColumnGroup();
oGroup.Text = "";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "COST COMPLET";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["cost_complet_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["cost_complet_cip"]);
dg_validare_antecalcul.Columns["cost_complet_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["cost_complet_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
oGroup.ShowHeader = false;
view.ColumnGroups.Add(oGroup);
// CSTB
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTB";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Profit";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTB_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTB_cip"]);
dg_validare_antecalcul.Columns["CSTB_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTB_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTC
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTC";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Ch. generale de administratie";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTC_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTC_cip"]);
dg_validare_antecalcul.Columns["CSTC_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTC_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTD
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTD";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Costuri desfacere";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTD_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTD_cip"]);
dg_validare_antecalcul.Columns["CSTD_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTD_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTE
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTE";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Cost de productie antecalculat-total";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTE_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTE_cip"]);
dg_validare_antecalcul.Columns["CSTE_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTE_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTF
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTF";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Ch. indirecte af. Diviziei strategice";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTF_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTF_cip"]);
dg_validare_antecalcul.Columns["CSTF_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTF_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTG
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTG";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Ch. indirecte af. Diviziei conducatoare";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTG_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTG_cip"]);
dg_validare_antecalcul.Columns["CSTG_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTG_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTH
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTH";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Cost de productie antecalculat-propriu";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTH_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTH_cip"]);
dg_validare_antecalcul.Columns["CSTH_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTH_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTI
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTI";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Ch. indirecte de sectie";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTI_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTI_cip"]);
dg_validare_antecalcul.Columns["CSTI_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTI_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTJ
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTJ";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Materiale directe";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTJ_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTJ_cip"]);
dg_validare_antecalcul.Columns["CSTJ_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTJ_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTK
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTK";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Nevoi proprii directe";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTK_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTK_cip"]);
dg_validare_antecalcul.Columns["CSTK_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTK_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTL
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTL";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Chelt. cu scule";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTL_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTL_cip"]);
dg_validare_antecalcul.Columns["CSTL_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTL_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTM
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTM";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Ch. transp-aprov.";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTM_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTM_cip"]);
dg_validare_antecalcul.Columns["CSTM_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTM_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTN
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTN";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Manopera directa";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTN_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTN_cip"]);
dg_validare_antecalcul.Columns["CSTN_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTN_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTO
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTO";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Indexare manop. directa ramasa";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTO_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTO_cip"]);
dg_validare_antecalcul.Columns["CSTO_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTO_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTP
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTP";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Ch. salarii colaboratori";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTP_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTP_cip"]);
dg_validare_antecalcul.Columns["CSTP_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTP_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTQ
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTQ";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "C.A.S. si alte fonduri af.(manop. directe+sporuri)";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTQ_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTQ_cip"]);
dg_validare_antecalcul.Columns["CSTQ_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTQ_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTR
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTR";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "S.D.V. directe";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTR_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTR_cip"]);
dg_validare_antecalcul.Columns["CSTR_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTR_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTS
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTS";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Alte costuri directe";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTS_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTS_cip"]);
dg_validare_antecalcul.Columns["CSTS_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTS_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTT
oGroup = new GridViewColumnGroup();
oGroup.Text = "CSTT";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Colaborari directe";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTT_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTT_cip"]);
dg_validare_antecalcul.Columns["CSTT_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTT_cip"].HeaderText = "CIP";
oGroup.Groups.Add(oSubGroup);
view.ColumnGroups.Add(oGroup);
// CSTU
//GridViewColumnGroup oGroup1 = new GridViewColumnGroup();
//oGroup1.Text = "";
GridViewColumnGroup oGroupU = new GridViewColumnGroup();
oGroupU.Text = "CSTU";
oSubGroup = new GridViewColumnGroup();
oSubGroup.Text = "Utilitati directe";
oSubGroup.Rows.Add(new GridViewColumnGroupRow());
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTU_unitar"]);
oSubGroup.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTU_cip"]);
dg_validare_antecalcul.Columns["CSTU_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTU_cip"].HeaderText = "CIP";
oGroupU.Groups.Add(oSubGroup);
//oGroup1.Groups.Add(oGroupU);
view.ColumnGroups.Add(oGroupU);
// CSTV
GridViewColumnGroup oGroupV = new GridViewColumnGroup();
oGroupV.Text = "CSTV";
GridViewColumnGroup oSubGroupV = new GridViewColumnGroup();
oSubGroupV.Text = "Corectii";
oSubGroupV.Rows.Add(new GridViewColumnGroupRow());
oSubGroupV.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTV_unitar"]);
oSubGroupV.Rows[0].Columns.Add(dg_validare_antecalcul.Columns["CSTV_cip"]);
dg_validare_antecalcul.Columns["CSTV_unitar"].HeaderText = "UNITAR";
dg_validare_antecalcul.Columns["CSTV_cip"].HeaderText = "CIP";
oGroupV.Groups.Add(oSubGroupV);
//oGroup1.Groups.Add(oGroupV);
//oGroup1.ShowHeader = false;
//view.ColumnGroups.Add(oGroup1);
view.ColumnGroups.Add(oGroupV);
dg_validare_antecalcul.ViewDefinition = view;[/QUOTE]
Comment any of the of the grouping and fill grid works. With all the groups the fill grid gives error at the last line. In my opinion it is because telerik controls think that there too many groups.
Any help is appreciated and thank you for your time and effort.