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

Using Dynamic XML as a DataSource

5 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SchaF
Top achievements
Rank 1
SchaF asked on 02 Feb 2012, 04:25 PM
Im still very new to Telerik and some of the more advanced features of c#(considering I just graduated in December). I dont really know how to use IEnumerable or an ICollection or ObervableCollection, so I was wondering if someone could point me in the direction to help me take my parsed XML(dynamic here), which has different elements every time so Im using Linq to XML with Key/Value pairs, and set it up in a way to use as the ItemsSource for the GridView.

Would it be possible to build a List<GridViewRow> or even an ArrayList of GridViews or GridViewRow[] and bind that as the data source for my GridView. I tried it before creating a new GridViewRow and for each Key/Value pair, I created a new cell in the row, added the value of the pair to the cells content and then added that to a List<GVR>. However this didnt produce the correct results.

Could someone link me to a tutorial or a demo made for relatively new people to telerik and binding data to its ItemsSource?

5 Answers, 1 is accepted

Sort by
0
SchaF
Top achievements
Rank 1
answered on 03 Feb 2012, 08:35 PM
Please help. Ive tried creating an ObservableCollection<GridRow> and inserting or adding the rows and that didnt work. Ive also looked at these three places
http://blogs.telerik.com/vladimirenchev/posts/09-04-23/lightweight-datatable-for-your-silverlight-applications.aspx
http://blogs.telerik.com/vladimirenchev/posts/11-09-28/dynamic-binding-for-your-silverlight-applications.aspx
http://www.telerik.com/community/forums/silverlight/gridview/binding-dynamic-xml-to-the-gridview.aspx

and none of them have been able to help. I tried to use the second one but is says there no such class as System.Dynamic, and it finds errors all over the place with "IEnumerable<String>, GetDynamicMemberNames(), TryGetMember(GetMember binder...,[binder.Name];, TrySetMember(SetMemberBinder....,ObservableCollection<dynamic> collection;" they all give me errors.

Just as clarification, Im getting dynamic XML with a different number of 'column' or xml elements, every time, so I cant create a class for it and I assuming I need a dynamic class.
0
SchaF
Top achievements
Rank 1
answered on 07 Feb 2012, 06:27 PM
So here is my ultimate problem. When I get a "column/element" back in the xml, its already been parsed to remove XMl characters such as / -> x002F etc. I have successfully built a dynamic object with a get and set method after running a linq to xml query to go row by row, creating the object and add it a list(that is an implicitly typed variable made up of my dynamic object) that is eventually returned as "return list as IEnumerable". Its basically an ObservableCollection<DataObject> (DataObject being my dynamic object) and the problem is that just before adding the object to a list, the cell/column pair has the correct data that is supposed to be there, but when it shows up in the gridview, the data under any column with a /, disappears. Is this a problem with Teleriks GridView or something in my dynamic object. FYI, I'm XMLConverting everything to parse the data without the x002F and other xml characters.
0
SchaF
Top achievements
Rank 1
answered on 07 Feb 2012, 07:16 PM
After looking at this some more and being able to loop through the finished and populated list just before returing it as the itemsSource, Ive found the problem to be the telerik gridview control. For some reason, it does not want to display a column that has a '/'(and most likely no ' ' '\'  along with many other characters that cannot be in an xml element) as a part of the ItemsSource IEnumerable list that is being returned to it. Can someone please tell me whats going on with this and how to fix this issue. Im using a silverlight 3 application, along with Telerik Silverlight v2009.3.1314.1030.

Ive checked numerous and the data 'list'(observablecollection of dynamic object) is correct and has all of the correct data in it, however when I return the 'list' as IEnumerable to the gridview.ItemsSource, it fails to correctly display the cells for the column that has the / in it.
0
Vlad
Telerik team
answered on 08 Feb 2012, 08:49 AM
Hi,

 I'm afraid that both Silverlight 3 and this version are no longer supported. Please upgrade to our latest official version - Q3 2011 SP1. You can wait till next week if you want since we are about to release our Q1 2012.

Kind regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
SchaF
Top achievements
Rank 1
answered on 08 Feb 2012, 04:06 PM
Is that going to solve my problem. If its something for SL5, and Im using SL3, how will that fix my problem?
Tags
GridView
Asked by
SchaF
Top achievements
Rank 1
Answers by
SchaF
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or