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

Telerik Silverlight Datatable

3 Answers 141 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
George Fryberger
Top achievements
Rank 1
George Fryberger asked on 31 Aug 2010, 10:12 PM
I need to be able to serialize the class that can be found on this Telerik blog.

Download Class

I am trying to do this from within a Silverlight project to cache the data to the IsolatedStorageFile using the XMLSerializer.  The problem that I am having is that I am getting an error message stating

To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. Telerik.Data.DataTable does not implement Add(System.Object).

I have been trying to modify the class to include an "Add" method but I have been unable to get it to work and I am uncertain as to what I am doing wrong.

I know that this is only loosely related to Telerik and their products, but I would greatly appreciate any assistance that anyone can provide.

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 07 Sep 2010, 08:38 AM
Hi,

 You may need to change a bit our DataTable to be IList instead IEnumerable. You can find our latest code here

Regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Italcoppie Sensori S.R.L.
Top achievements
Rank 1
answered on 27 May 2011, 09:06 AM
Hi, when I click on btnTest button to add a column to my datatable, I receive this error message:

 

 

"Collection is read-only."
Could you help me plese? Below you can see my snipped code.
Thanks

DataTable
dt = null ;
 
 

 

 

public ucTab01() 

 

InitializeComponent(); 

 

GetDT();
}

 

 

 

 

 

void 

 

 

GetDT()  

{

 

 

dt = new DataTable(); 

dt.Columns.Add(new DataColumn() { ColumnName = "Col1", DataType = typeof(string) });
DataRow row = dt.NewRow(); 

 

 

row["Col1"] = "test";

 

 

dt.Rows.Add(row);

 

 

this.RadGridView01.ItemsSource = dt.ToList();

 

}
 
 

 

 

 

private void btnTest_Click(object sender, RoutedEventArgs

e) 

{

 

dt.Columns.Add(

 

new DataColumn() { ColumnName = "Col2", DataType = typeof(decimal

) }); //This is my ERROR!

 

}

 

 

0
Maya
Telerik team
answered on 01 Jun 2011, 12:09 PM
Hello,

Indeed, once the DataTable is set as the ItemsSource for the grid, its Columns collection gets read-only. What you may try to do is to create a new one with the same data plus the additional column that you want and set this new DataTable as data source for the RadGridView. 

Regards,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
George Fryberger
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Italcoppie Sensori S.R.L.
Top achievements
Rank 1
Maya
Telerik team
Share this question
or