• Home
  • About
  • Resume

Solution for WebHierarchicalDataGrid’s “Async request failed” error

By , 04/29/2013 4:28 PM

This is a solution for specific (and maybe somewhat obscure, but it helped me, so perhaps it will be helpful to someone else) scenario for Infragistics’ WebHierarchicalDataGrid error “Async request failed“.

It could be accompanied by inner errors

Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request

or more generic

Object Reference not set

In this particular scenario WHDG uses manual LoadOnDemand for to populate children (i.e. RowIslandPopulating event is used) and parent grid is sorted by one or more columns. Error is happening when attempting to expand second child or a grandchild.

Chances are you’re manually populating SortedColumns collection of the parent grid:

For '..some loop condition
   xMyGrid.Behaviors.Sorting.SortedColumns.Add() '...adding to SortedColumns
Next

If so – the errors mentioned above happen because this code is called on page postback. To avoid them just check for the postback and if it is happening skip the code:

If Not IsPostBack Then 'Don't do this on PostBack
   For '..some loop condition
         xMyGrid.Behaviors.Sorting.SortedColumns.Add() '...adding to SortedColumns
   Next
End If

It is possible that you absolutely must execute this code on some postbacks. Then you only need to skip it when Child RowIsland is being populated and execute it on all other postacks. It is possible with AJAX callback detection. If you use function from that post then the code for skipping sorting will become:

If GetGridAjaxCallType() <> GRID_AJAX_CALL_TYPE.CHILD_POPULATING Then
   For '..some loop condition
         xMyGrid.Behaviors.Sorting.SortedColumns.Add() '...adding to SortedColumns
   Next      
End If

Using this approach grid’s SortedColumns collection will be updated in all the cases *but* when child is populating, effectively preventing errors from happening.

Leave a Reply

Panorama Theme by Themocracy