This is a migrated thread and some comments may be shown as answers.

Q1 2011 BETA circular reference was detected

8 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Developix
Top achievements
Rank 1
Developix asked on 18 Mar 2011, 11:57 AM
Hi,
since updating to version 2011.1.224 i got the following error on my grid:

A circular reference was detected while serializing an object of type 'System.Data.DataRowView'.


The grid uses server binding. The model is a classic DataTable.
This on works fine:

 

 

 

 

<% Html.Telerik().Grid(Model.Data)
        .Name("xxx")
        .TableHtmlAttributes(new { style = "table-layout:fixed" })
        .DataKeys(keys => keys.Add(c => c.Row["xxx"]))
        .Columns(columns =>
        {
                    columns.AutoGenerate(true);
        })
        .Render();  
%>

 

But when editing gets enabled, the error occurs:

 

 

 

<% Html.Telerik().Grid(Model.Data)
        .Name("xxx")
        .TableHtmlAttributes(new { style = "table-layout:fixed" })
        .DataKeys(keys => keys.Add(c => c.Row["xxx"]))
        .DataBinding(dataBinding => dataBinding
            .Server()
               .Update("action", "controller")
             )
        .Columns(columns =>
        {
            columns.Command(commands =>
            {
                commands.Edit();
            }).Width(170);      
            columns.AutoGenerate(true);
        })
        .Render();  
%>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

8 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 18 Mar 2011, 12:45 PM
Hi Developix,

Indeed this is a known issue which should be addressed in the official Q1 2011 release. Therefore, please download the Q1 2011 official and give it a try.

All the best,
Rosen
the Telerik team
0
Developix
Top achievements
Rank 1
answered on 18 Mar 2011, 02:26 PM
Thanks for the quick response. Now the grid and edit button is displayed again.
But if i click on Edit an exception is thrown. I think this comes from the datakey. 
but my datakey is never null...
 
System.ArgumentNullException was unhandled by user code
  Message=Value cannot be null.
Parameter name: key
  Source=mscorlib
  ParamName=key
  StackTrace:
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
       at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector)
       at Telerik.Web.Mvc.UI.GridDataKeyStore.GetDataKeyValues(Object dataItem)
       at Telerik.Web.Mvc.UI.Html.GridHtmlHelper`1.HiddenForDataKey(Object dataItem)
       at Telerik.Web.Mvc.UI.Html.GridButtonBuilder.AppendDataKeys(IHtmlNode container, Object dataItem)
       at Telerik.Web.Mvc.UI.Html.GridButtonBuilder.Create(Object dataItem)
       at Telerik.Web.Mvc.UI.Html.GridActionCellBuilder.AppendCellContent(IHtmlNode td, Object dataItem)
       at Telerik.Web.Mvc.UI.Html.GridDataCellBuilderBase.CreateCell(Object dataItem)
       at Telerik.Web.Mvc.UI.Html.GridInLineEditRowBuilder.AppendEditor(IHtmlNode container)
       at Telerik.Web.Mvc.UI.Html.GridInLineEditRowBuilder.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridRowBuilderDecoratorBase.CreateRow()
       at Telerik.Web.Mvc.UI.Html.GridDataSectionBuilder.CreateBody(IEnumerable`1 rowBuilders)
       at Telerik.Web.Mvc.UI.Html.GridDataSectionBuilder.CreateBody(GridRenderingData renderingData)
       at Telerik.Web.Mvc.UI.Html.GridHtmlBuilder.CreateBody(GridRenderingData renderingData)
       at Telerik.Web.Mvc.UI.Html.GridHtmlBuilder.AppendData(IHtmlNode div, GridRenderingData renderingData)
       at Telerik.Web.Mvc.UI.Html.GridHtmlBuilder.CreateGrid(IDictionary`2 htmlAttributes, GridFunctionalData functionalData, GridRenderingData renderingData)
       at Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer)
       at Telerik.Web.Mvc.UI.ViewComponentBase.Render()
       at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render()
       at ASP.views_commonparts_listengines_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer) in e:\Work_SVN\uptime\locate\trunk\web\Locate\Views\CommonParts\ListEngines.aspx:line 16
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.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 ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in e:\Work_SVN\uptime\locate\trunk\web\Locate\Views\Shared\Site.Master:line 34
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.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.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.Mvc.ViewPage.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)
  InnerException: 
0
Accepted
Rosen
Telerik team
answered on 19 Mar 2011, 09:51 AM
Hi Developix,

I was able to observed the described error. It seems that it is cause by the fact that MVC3 metadataprovider does not support DataTables and will throw if unobtrusive validation is enabled. However, we have applied a workaround in our code and I have attached an internal build which should address this issue.

Best wishes,
Rosen
the Telerik team
0
Developix
Top achievements
Rank 1
answered on 21 Mar 2011, 08:57 AM
Hi, thank your for this quick response.

I upgraded everything to 2011.1.319, but i still get this error, can you please verify.
0
Rosen
Telerik team
answered on 21 Mar 2011, 09:52 AM
Hi Developix,

I suspect that you may be getting the error from the use of MVC built-in html helpers if you have such in the editor template for example. This is caused by the fact that when unobtrusive validation is enabled, the MetaDataProvider will try to read the properties of the bound item (DataRowView) and append various attributes to the generated input element. Unfortunately, it seems that the MetaDataProvider does not support DataTables/DataRowView, therefore you may need to disable the unobtrusive validation feature for the pages where binding to DataTable is required.

All the best,
Rosen
the Telerik team
0
Developix
Top achievements
Rank 1
answered on 21 Mar 2011, 10:25 AM
Hi,
if i do it in this way, the error still persists:

protected void Application_Start()
{
            HtmlHelper.UnobtrusiveJavaScriptEnabled = false;
            HtmlHelper.ClientValidationEnabled = false; 
}


Is the hotfix from 2011.1.319 not working?
0
Rosen
Telerik team
answered on 21 Mar 2011, 11:19 AM
Hello Developix,

It seems to be working on my end. Can you please check the attached sample project.


Rosen
the Telerik team
0
Developix
Top achievements
Rank 1
answered on 22 Mar 2011, 08:11 PM
Hi,
thanks for this very good support.

I have become my application running again.
 
I think your hotfix 2011.1.319 is working very well.
The only i thing i had to change in my code after applying the patch was,
the way i build up the data key.

Not working any more:
.DataKeys(keys => keys.Add(c => c.Row["xxx"])) 
  
Works:
.DataKeys(dataKeys => dataKeys.Add("xxx"))

It is also still working if i set unobtrusive validation enabled:

HtmlHelper.UnobtrusiveJavaScriptEnabled = true;

Tags
Grid
Asked by
Developix
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Developix
Top achievements
Rank 1
Share this question
or