I'm having following problem in the WebDataGrid:
I created a small project to show you what is my problem. I have a page with a webDataGrid and a drop down list that is used to change datasource in the grid.
Changing the datasource works fine until you sort or filter by any column. Although, I'm clearing the data source on drop down change as well as clearing sorting and filtering behaviors. But I'm getting this error.
[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.Web.UI.GridControls.Sorting.BehaviorEvents_PreRender(Object sender) +468 Infragistics.Web.UI.GridControls.RenderingContentHandler.Invoke(Object sender) +0 Infragistics.Web.UI.GridControls.GridBehaviorEvents.OnRenderingContent() +74 Infragistics.Web.UI.GridControls.GridRenderer.RenderContents(HtmlTextWriter writer) +281 Infragistics.Web.UI.Framework.RunBot.HandleRenderContents(HtmlTextWriter writer, RendererBase renderer) +135 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RenderContents(HtmlTextWriter writer) +74 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.Render(HtmlTextWriter writer) +39 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.Page.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
Please see attached zip file.
Thanks
OscarG
Hi,
Yes there appears to be a problem related to timing of the events on the server. Basically the data source is switched first and the the changes from the client applied again restoring the sorted columns collection.
We can certainly adjust that in our code.
In the meantime you can use a flag to defer switching the data source:
bool _dataSourceChanged = false;
protected void DataSourceDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
this._dataSourceChanged = true;
}
protected override void OnPreRender(EventArgs e)
if (this._dataSourceChanged)
AuditDataWebGrid.ClearDataSource();
AuditDataWebGrid.Behaviors.Filtering.ClearBehaviorColumnInfo();
AuditDataWebGrid.Behaviors.Sorting.SortedColumns.Clear();
LoadData();
base.OnPreRender(e);
Hi Alex,
I tried your suggestion but still having some issues.
It worked fine in the following case: If I change datasource from "choose datasource" to "datasource 1" and sort by Column "ID", then change datasource to "datasource 2", it clears the sort indicator fine, before it was throwing the error. Now if you sort by column "ID2" then I'm getting following error: Cannot find column ID.
I am having a similar issue. I can load the grid and click on the hyperlinks and everything works fine...but if I sort a column, a click on the hyperlinks generates an error and the debugger sends me to something on the master page but the error is object reference not set to an instance of an object. At first I thought it was a master page issue but why doesn't it occur from the grid with no sorting. So I removed the line that was generating the error on the master page and reran and it got this:
[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.Web.UI.GridControls.Sorting.AddHeaderImgToCaption(GridField column, SortDirection direction) +427 Infragistics.Web.UI.GridControls.Sorting.BehaviorEvents_PreRender(Object sender) +234 Infragistics.Web.UI.GridControls.RenderingContentHandler.Invoke(Object sender) +0 Infragistics.Web.UI.GridControls.GridBehaviorEvents.OnRenderingContent() +74 Infragistics.Web.UI.GridControls.GridRenderer.RenderContents(HtmlTextWriter writer) +283 Infragistics.Web.UI.Framework.RunBot.HandleRenderContents(HtmlTextWriter writer, RendererBase renderer) +135 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RenderContents(HtmlTextWriter writer) +73 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.Render(HtmlTextWriter writer) +39 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19 System.Web.UI.Page.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
Which points to the control as the issue...please help.
Hello koneal,
Can you tell me what version and build of our controls do you use in this application?
Since this scenario appears to be more complex (master page, hyperlinks etc.) it will be very helpful if you can attach a runnable sample reproducing this behavior to this thread or provide complete steps to build one.
This will allow us to run and debug it on our side and find the possible cause for this exception.
If the sample is too large or contains private data you can create a support case and attach it there.
I can also create a new support case for you if you have difficulties in creating one yourself.
I am waiting for your reply.
We are using 11.2.20112.1019. Putting together a sample would be difficult with the database and everything. We can certainly send the aspx page and even the master page.
We also have been having some speed issues that seem to be because of the binding of the control located in the Page_Load. It seems the grid needs the binding procedure in the page load to properly function when sorting but when clicking on a command button the binding reoccurs and is slowing down our application.
First thing that you should do in this situation is to install the latest Service Release (build 2055) and test if the issue will be present again.
If the latest Service Release does not correct this issue you can attempt to create an empty web site and add grid with the same setup and similar templates, columns, links etc.
If the same exception appears again you should attach this sample and we will debug and test it on our side.
See my post here:
http://blogs.infragistics.com/forums/p/49434/347010.aspx#347010
Maybe that solution will work for you and it isn't too late.
I have same problem:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error:
Line 219: Line 220: string imageHtml = string.Format(ImageElementFormat, imageId, imageUrl, "", imageAlt); Line 221: if (column.HeaderCaption.XmlAttributes["postText"] == null || (string)(column.HeaderCaption.XmlAttributes["postText"]) == string.Empty) Line 222: column.HeaderCaption.XmlAttributes["postText"] = imageHtml; Line 223: else
Source File: C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\Sorting\Sorting.cs Line: 221
[NullReferenceException: Object reference not set to an instance of an object.] Infragistics.Web.UI.GridControls.Sorting.AddHeaderImgToCaption(GridField column, SortDirection direction) in C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\Sorting\Sorting.cs:221 Infragistics.Web.UI.GridControls.Sorting.BehaviorEvents_PreRender(Object sender) in C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\Sorting\Sorting.cs:180 Infragistics.Web.UI.GridControls.RenderingContentHandler.Invoke(Object sender) +0 Infragistics.Web.UI.GridControls.GridBehaviorEvents.OnRenderingContent() in C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\GridBehaviorEvents.cs:501 Infragistics.Web.UI.GridControls.GridRenderer.RenderContents(HtmlTextWriter writer) in C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\GridControls\WebDataGrid\GridRenderer.cs:67 Infragistics.Web.UI.Framework.RunBot.HandleRenderContents(HtmlTextWriter writer, RendererBase renderer) in C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\Framework\RunBot.cs:239 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.RenderContents(HtmlTextWriter writer) in C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\Framework\Data\FlatDataBoundControl.cs:503 Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.Render(HtmlTextWriter writer) in C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\Framework\Data\FlatDataBoundControl.cs:519 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100......
Error is unstable and appears after asyncronous postback occurs from the DropDownList control (the SelectedIndexChanged event).The error occurs only when the SelectedIndexChanged is the first postback after login. If you press F5 on the page before change of DropDownList control - than works fine.
I use NetAdvantage ASP.NET 2010.3.2217 CLR4x (.net 4 framework).
In the process of debugging I found that the value of the variable column is NULL at C:\work\NetAdvantage_ASPNET_20103_2217_CLR4x\Infragistics.Web.UI\GridControls\WebDataGrid\Behaviors\Sorting\Sorting.cs ( Line: 221).