Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:31:02+00:00 2026-06-10T11:31:02+00:00

I have an XML File resembling the following: <root> <parent label=parent1> <child label=child1> <element1>data</element1>

  • 0

I have an XML File resembling the following:

<root>
   <parent label="parent1">
      <child label="child1">
         <element1>data</element1>
         <element2>data</element2>
         ...
         <grandchildren>
             <grandchild label="grandchild1">
                 <elementa>data</elementa>
                 <elementb>data</elementb>
             </grandchild>
         </grandchildren>
      </child>
      <child label="child2">
         <element1>data</element1>
         <element2>data</element2>
         ...
         <grandchildren>
             <grandchild label="grandchild2">
                 <elementa>data</elementa>
                 <elementb>data</elementb>
             </grandchild>
         </grandchildren>
      </child>
   </parent>
</root>

The XML serves as data source for a treeview. Users can select a parent there, and the properties of the parent will be displayed in a listview (which uses a LINQdataview as data source). I’m pulling the data out using a linq query. However, I would like to display the GrandChildren in a seperate control (a Telerik grid).

I created a new XMLDataSource in the listview cell, which will pull its data from the child’s xPAth (something I add in the code, see below), as well as the intended grid. The grid is set to have the XMLDataSource as its DataSourceID.

Here’s the code I use to pull the data in the Selecting event:

protected void listsSource_Selecting(object sender, LinqDataSourceSelectEventArgs e) {
    XElement rootElement = XElement.Load(MapPath(TreeSource.DataFile));

    parentElement = rootElement.XPathSelectElement("//parent[@label='" + tvw.SelectedNode.Text + "']");

    var query = from element in parentElement.DescendantsAndSelf("child")
        select new {
            element1 = element.Element("element1").Value,
            element2 = element.Element("element1").Value,                               
            xPathAddress = "//parent[@label='" + tvw.SelectedNode.Text + "']",
            grandchildrenXPath = "//parent[@label='" + tvwMaterials.SelectedNode.Text + "']" + "/grandchildren"
    };

    e.Result = query;
}

Here’s the code from the ASPX:

<td rowspan="7" style="border-style: solid; border-width: thin" align="center">
    <telerik:RadGrid ID="gridRelatives" runat="server" DataSourceID="XmlRelatives" >
                                </telerik:RadGrid>
    <asp:XmlDataSource ID="XmlRelatives" runat="server"
        DataFile="~/XML/Data/relatives.xml" xPath='<%# Eval("grandchildrenPath") %>'></asp:XmlDataSource>
</td>

However, this leads to a “Cannot find any bindable properties in an item from the datasource” error, and I am guessing that this is because of attempting to load the XML dynamically, causing it not to trigger when the ListSource selecting event fires.

Should I instead load the data in a seperate query statement, or am I overlooking something fairly simple?

Any help would be greatly appreciated, as this has had me stumped for a while now 🙂

Thanks.

Update:

Tried adding a second linq query to the selecting code, in an attempt to set the XPath part of a second XMLDataSource, but this gives me another error. Code:

var query2 = from element in parentElement.DescendantsAndSelf("child")
    select new {
        grandchildrenXPath = "//parent[@label='" + tvw.SelectedNode.Text + "']" + "/grandchildren"
    };
myThickness.XPath = query2.ToString();
myThickness.DataBind();

Error:

‘System.Linq.Enumerable+WhereSelectEnumerableIterator2[System.Xml.Linq.XElement,<>f__AnonymousType31[System.String]]’ has an invalid token.

Commenting the new lines has things working again.

I’m still hoping to find a solution for this. I imagined that building the xPath dynamically would be a great way to accomplish this, but obviously that is a no-go. What am I not seeing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:31:03+00:00Added an answer on June 10, 2026 at 11:31 am

    I ended up figuring out a workaround by adding a new XMLDataSource and loading that within the listsSource_Selecting event.

    I tried doing this before, but placed the code above the LINQ query that feeds the ListView this time. That does not throw any errors anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have XML file in the following format; <root> <entry> <details> </entry> <entry> <details>
I have an xml file with the following structure: <main_tag> <first> <tag1>val1</tag1> <conf> <tag2>val2</tag2>
I have XML files containing data like this... <parent> <boy/> </parent> <parent> <girl/> <parent>
If I have XML like this: <sample> <a:element1 xmlns:a=... /> <b:element2 xmlns:b=... /> </sample>
I have xml file whose structure is defined with following xsd: <?xml version=1.0 encoding=utf-8?>
I have XML file (output of some application) like this: <data> <call function=get_user_data> <output>
I have xml file like following for displaying ads using asp:AdRotator in asp <?xml
I have a file, which is in XML format (consists just of root start
I have XML file: ... <Chart id=c01> <expires>2012-07-19 12:20:00</expires> <data><![CDATA[...]]></data> </Chart> ... where CDATA
i have xml file such as following. <?xml-stylesheet type='text/xsl' href='AdditionalLogInfo.xsl'?> <Logs> <Log TestName=EwireDepositTests Date=Oct

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.