We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

[NullReferenceException: Object reference not set to an instance of an object.]

Hello,

I have a grid that binds a datasource. Now that the number of columns in the datasource are changed when the grid loads, I get above error. Please see the following stack trace

[NullReferenceException: Object reference not set to an instance of an object.]
Syncfusion.Web.UI.WebControls.Grid.Grouping.Utils.GetRecordId(Record r)
Syncfusion.Web.UI.WebControls.Grid.Grouping.Utils.GetTableElementKey(Object tableElement)
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridRow..ctor(Element e, GridTable gTable, GridGroupingControl parent, Int32 eIndex)
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.CreateRowFromDisplayElement(Element e, Int32 rowIndex, GridTable gTable)
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.RenderVisiblePage(Table table, GridTable gTable, ChildTable cTable, PageInfo pi, GridPageInfo gpi, Boolean currentRecordFound)
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.InitHtmlTableFromGridTable(Table table, GridTable gTable, ChildTable cTable, Int32 curPage, Int32 pageSize)
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.CreateControlHierarchy()
Syncfusion.Web.UI.WebControls.Grid.Grouping.GridGroupingControl.OnPreRender(EventArgs e)
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Control.PreRenderRecursiveInternal()
System.Web.UI.Page.ProcessRequestMain()

Any suggestions/comments would appreciated

1 Reply

MW Melba Winshia Syncfusion Team October 31, 2007 08:03 AM UTC

Hi Mahesh,

We regret for the delayed response.

Normally if a grid is bound with datasource and then you are changing the columns in the datasource, you should rebind the datasource to grid by using the below code snippet:

[C#]

this.gridGroupingControl1.DataSource = null;
this.gridGroupingControl1.DataMember = null;
this.gridGroupingControl1.ResetTableDescriptor();
this.gridGroupingControl1.TableDescriptor.Relations.Clear();
this.gridGroupingControl1.DataSource = newdatasource;
this.gridGroupingControl1.Refresh();

Please refer the sample in the below link which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Web/5.2.0.25/69344_1/main.htm

Please have a look at the above sample and if still the issue exists, could you please try reproducing it in the above sample and send us the modified sample so that we could sort out the cause of the issue and provide you a solution?

Thanks,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon