XML Binding

3 posts, 0 answers
  1. Fábio
    Fábio avatar
    5 posts
    Member since:
    Sep 2010

    Posted 26 Dec 2010 Link to this post

    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. Fábio
    Fábio avatar
    5 posts
    Member since:
    Sep 2010

    Posted 29 Dec 2010 Link to this post

    Hello !?

    Any clue for my question ?
  3. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 03 Jan 2011 Link to this post

    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
Back to Top