Hi,
I have a webdatagrid were I enabled sorting, but it doesn't seem to work, I receive a javascript error.
Error: Sys.ArgumentException: Cannot deserialize. The data does not correspond to valid JSON.Parameter name: data
Here you have a sample of the webdatagrid
<ig:WebDataGrid ID="WebDataGrid1" runat="server" DataKeyFields="ID" AutoGenerateColumns="False" EnableAjax="true" Width="602px" ShowFooter="true"><Columns> <ig:TemplateDataField Key="DateTime" Width="150px"> <ItemTemplate> <%#DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "DateTime")%> </ItemTemplate> <Header Text="DateTime" /> </ig:TemplateDataField> <ig:TemplateDataField Key="Component" Width="363px"> <ItemTemplate> <%#DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "Component")%> </ItemTemplate> <Header Text="Component" /> </ig:TemplateDataField> <ig:TemplateDataField Key="Sevirity" Width="65px"> <ItemTemplate> <img src="img/sevirity<%#DataBinder.Eval(CType(Container, Infragistics.Web.UI.TemplateContainer).DataItem, "Sevirity").ToString().Trim()%>.png" alt="" /> </ItemTemplate> <Header Text="Sevirity" /> </ig:TemplateDataField></Columns><Behaviors> <ig:Sorting SortingMode="Multi" Enabled="true"> <ColumnSettings> <ig:SortingColumnSetting ColumnKey="DateTime" Sortable="true"/> <ig:SortingColumnSetting ColumnKey="Component" Sortable="true"/> <ig:SortingColumnSetting ColumnKey="Sevirity" Sortable="true"/> </ColumnSettings> </ig:Sorting></Behaviors></ig:WebDataGrid>
I have a DataTable which I bind to the WebDataGrid.
WebDataGrid1.DataSource = dtWebDataGrid1.DataBind()
How can I fix this problem?
Edit:
I was able to catch the following information:
Source: Infragistics35.Web.v9.1
Class: Sorting
Stacktrace:
at Infragistics.Web.UI.GridControls.Sorting.BehaviorEvents_PreRender(Object sender) at Infragistics.Web.UI.GridControls.GridBehaviorEvents.RenderingContentHandler.Invoke(Object sender) at Infragistics.Web.UI.GridControls.GridBehaviorEvents.OnRenderingContent() at Infragistics.Web.UI.GridControls.GridRenderer.RenderContents(HtmlTextWriter writer) at Infragistics.Web.UI.Framework.RunBot.HandleRenderContents(HtmlTextWriter writer, RendererBase renderer) at Infragistics.Web.UI.GridControls.WebDataGrid.GetRenderHTML() at Infragistics.Web.UI.GridControls.WebDataGrid.CallbackRender(CallbackObject callbackObject) at Infragistics.Web.UI.Framework.Data.FlatDataBoundControl.Infragistics.Web.UI.IControlCallback.CallbackRender(CallbackObject callbackObject) at Infragistics.Web.UI.Framework.RunBot.CallbackRenderRecursive(CallbackObject callbackObject) at Infragistics.Web.UI.Framework.RunBot.RenderFormCallBack(HtmlTextWriter writer, Control control) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) at Infragistics.Web.UI.Framework.RunBot.RenderPageCallBack(HtmlTextWriter writer, Control control) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) at System.Web.UI.Page.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) at System.Web.UI.Control.RenderControl(HtmlTextWriter writer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Hi, I was a bit busy in other project and didn't follow up.
I figured it out what is the problem.
I am using a custom error page and because at an AJAX partial postback I forgot to rebind the datatable to the grid, the custom error page was returned. This is causing the mentioned error.
So I added the following code in the Page_Load at postback:
If Not (Request.Params("__IGCallback_" & WebDataGrid1.ClientID) Is Nothing) Then ' Handle Sorting and Page Index changes. If (Request.Params("__IGCallback_" & WebDataGrid1.ClientID).Contains("ColumnSorting")) Then LoadData() ElseIf (Request.Params("__IGCallback_" & WebDataGrid1.ClientID).Contains("PageIndexChanging")) Then LoadData() End If End If
The function LoadData() will actually rebind the datatable to the WebDataGrid1.
An advice to all who concern: Do some error handling inside the global.asax and when you encounter an error set a breakpoint in the global.asax and check the error message.
An example:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Get reference to the source of the exception chain Dim ex As Exception = Server.GetLastError().GetBaseException() If Not (ex Is Nothing) Then Dim errorCode As String = String.Empty Select Case ex.GetType().Name Case "HttpException" errorCode = DirectCast(ex, HttpException).ErrorCode End Select ' Get the website version information Dim version As String = "1.0" If Not (Application.Item("Version") Is Nothing) Then version = Application.Item("Version") End If If (errorCode = "-2147467259") Then ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ++Information about ErrorCode = -2147467259++ ' ***************************************** ' ' Class {StaticFileHandler} ' Method {GetFileInfo} ' Parameter SP {} ' Parameter Parameters {IP address = , Hostname = , Logon user = } ' Error Message {File does not exist. - Filepath} ' Stack Trace {at System.Web.StaticFileHandler.GetFileInfo(String virtualPathWithPathInfo, String physicalPath, HttpResponse response) ' at System.Web.StaticFileHandler.ProcessRequestInternal(HttpContext context) ' at System.Web.DefaultHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback callback, Object state) ' at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() ' at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)} ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim filePath As String = Context.Request.FilePath Com_Logging.LogInfo("Class {" & ex.TargetSite.ReflectedType.Name & "}" & vbCrLf & _ "Method {" & ex.TargetSite.Name & "}" & vbCrLf & _ "Parameter SP {}" & vbCrLf & _ "Parameter Parameters {IP address = " & GetCurrentIP() & ", Hostname = " & GetCurrentHOST() & ", Logon user = " & GetCurrentLOGONUSER() & ", Website version = " & version & "}" & vbCrLf & _ "Error Message {" & ex.Message & " - " & filePath & "}" & vbCrLf & _ "Stack Trace {" & ex.StackTrace & "}", LogType.ErrorFlag, "Application_Error", False) Else Com_Logging.LogInfo("Class {" & ex.TargetSite.ReflectedType.Name & "}" & vbCrLf & _ "Method {" & ex.TargetSite.Name & "}" & vbCrLf & _ "Parameter SP {}" & vbCrLf & _ "Parameter Parameters {IP address = " & GetCurrentIP() & ", Hostname = " & GetCurrentHOST() & ", Logon user = " & GetCurrentLOGONUSER() & ", Website version = " & version & "}" & vbCrLf & _ "Error Message {" & ex.Message & "}" & vbCrLf & _ "Stack Trace {" & ex.StackTrace & "}", LogType.ErrorFlag, "Application_Error", False) Select Case ex.GetType().Name Case "NotImplementedException" ex.HelpLink = "http://msdn.microsoft.com/en-us/library/system.notimplementedexception.aspx" Case "InvalidOperationException" ex.HelpLink = "http://msdn.microsoft.com/en-us/library/system.invalidoperationexception.aspx" Case "ArgumentNullException" ex.HelpLink = "http://msdn.microsoft.com/en-us/library/system.argumentnullexception.aspx" Case "ArgumentException" ex.HelpLink = "http://msdn.microsoft.com/en-us/library/system.argumentexception.aspx" Case "Exception" ex.HelpLink = "http://msdn.microsoft.com/en-us/library/system.exception.aspx" End Select End If 'Save the exception into a session variable for the error page. Session.Item("Exception") = ex End IfEnd Sub
I'm getting this exact same error. There are no special characters and the data source is 3 rows + 4 columns (just a test DataTable set to the Grid's datasource).
The interesting thing is it worked without a hitch on the VS2008 dev server (right click -> View in Browser). But I got the error when I tried to navigate to the page hosted in IIS.
As I was typing this I was debugging something else. And the problem is now gone. I don't recall all I did, I reset IIS several times but I'm not sure if I did so after seeing this error. I did disable and reenable AJAX on the grid. I wish I had written down specifically what I did. I apologize!
I'm going to post this anyway in case someone else has this same issue and finds this thread via google like me. I'm running XP Professional with IIS 5.1, VS2008 SP1, .NET 3.5 SP1, and Infragistics ASP.NET 9.1. I can't give much advice except that the problem may go away magically without you having to reconfigure IIS or get crazy with anything.
Best of luck,-Pete
Hello,
That's an interesting case. Are there any special characters in your data? How big is the data source?