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

XML Binding

2 Answers 33 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Fábio
Top achievements
Rank 1
Fábio asked on 27 Dec 2010, 03:05 AM
Hi friends,

I have the following XML:
<NewDataSet>
   <student id="001" name="Jonh"/>
   <student  id="002" name="Mary"/>
   <... .../>
<NewDataSet/>

It's in memory created XML and I need to bind it to a ComboBox.
To get the students from the XML string I'm using:
{
  XElement xmlDoc;
  ...
  xmlDoc = XElement.Parse(XMLString);
  ...
  var myQuery = from p in xmlDoc.Elements("student")
            select p;
  ...
  myComboBox.ItemsSource = myQuery;
}

In my combo, ValuePath is "ID" and MemberOath is "NAME".
Well, "You need to create a class..." you may say... but the XML data changes.
It can be Student ID, Student Name.... Student ID, Student Adress... Teacher ID, Teacher Name.... it's a very dynamic data with and ID and XYZ

How to bind this kind of XML ?

Best regards

2 Answers, 1 is accepted

Sort by
0
Fábio
Top achievements
Rank 1
answered on 29 Dec 2010, 12:34 PM
Hello !?

Any clue for my question ?
0
Valeri Hristov
Telerik team
answered on 03 Jan 2011, 12:14 PM
Hi Fábio,

You could either create several forms, containing different comboboxes, bound to the corresponding members, or create a class, that "knows" how to handle the different attribute names of the data XML. Unfortunately RadComboBox cannot automatically guess what's the correct member to bind to.

Best wishes,
Valeri Hristov
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
ComboBox
Asked by
Fábio
Top achievements
Rank 1
Answers by
Fábio
Top achievements
Rank 1
Valeri Hristov
Telerik team
Share this question
or