Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
375
Object reference not set to an instance of an object
posted

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

WebApplication1.zip
Parents
  • 14049
    Offline posted

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

    }

     

Reply Children