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
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.
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.
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);