We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with DataSourceCachingMode

Hi

I use the syncfusion grid control. When I set the property  DataSourceCachingMode="ViewState", the control doesn t works. I have this error : “Référence circulaire détectée lors de la sérialisation d'un objet de type 'System.Data.DataView'.

If i put DataSourceCachingMode="none", the controls works, but I don t want to load the grid each post back.

Can you help me?


3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team May 18, 2017 04:23 PM UTC

Hi Marchesini, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we suspect that you want to bind the dataTable to the Grid with the dDataSourceCachingMode as viewstate. We are able to reproduce the reported issue from our end. Because binding grid dataTable, when its go for postBack then it will need to get serialize. This is the root cause of the issue. 

Refer the below code example. 


public partial class _Default : Page 
    { 
         
        protected void Page_Load(object sender, EventArgs e) 
        { 
            var datatable = GetGridDT(); 
             
            var emp = (from DataRow row in datatable.Rows 
                       select new OrderTable 
                       { 
                           OrderID = Convert.ToInt32(row["OrderID"]), 
                           CustomerID = row["CustomerID"].ToString(), 
                           EmployeeID = Convert.ToInt32(row["EmployeeID"]), 
                           ShipCountry = row["ShipCountry"].ToString() 
 
                       }).ToList(); 
 
            this.FlatGrid.DataSource = emp; 
        } 
         
         
        public static DataTable GetGridDT() 
        { 
            var connection = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString; 
            var dataTable = new DataTable(); 
            using (var dataAdapter = new SqlDataAdapter("SELECT * from Orders", connection)) 
            { 
 
                dataAdapter.Fill(dataTable); 
 
            } 
            return dataTable; 
        } 


We have prepared a sample and it can be downloadable from the below location. 


If we misunderstood your query then please get back to us. 

Regards, 
Thavasianand S.


MA marchesini May 24, 2017 08:57 AM UTC

Thanks you.

I looked at your solution but the difference is that we use the grid in auto generated column. So with your solution we have the same error message.


TS Thavasianand Sankaranarayanan Syncfusion Team May 26, 2017 01:49 AM UTC

Hi Marchesini, 

We have analyzed your query and we suspect that you want to generate the columns as autogenerated for dataSourceCachingMode as viewState. So, we suggest you to use the DataTableToJson() method to convert the dataTable into Json.  

Refer the below code example. 

 
protected void Page_Load(object sender, EventArgs e) 
        { 
            var datatable = GetGridDT(); 
            var rows = Utils.DataTableToJson(datatable); 
            this.FlatGrid.DataSource = rows; 
        } 
 



                                                                                                                                                                         
  
We have prepared a sample and it can be downloadable from the below location. 


If you still face the same issue then please get back to us. 

Regards, 
Thavasianand S. 


Loader.
Live Chat Icon For mobile
Up arrow icon