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 171705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:02:07+00:00 2026-05-11T13:02:07+00:00

If I have a DataSet as a result of a SQL query, can I

  • 0

If I have a DataSet as a result of a SQL query, can I bind it directly to a TreeView and show the hierarchy of my data? I know I’d have to use several HierarchicalDataTemplates, but I don’t know how to tell each one what data to display.

If I have a 4-level hierarchy, like so:

<HierarchicalDataTemplate x:Key='FirstLevelTemplate' ItemTemplate='{StaticResource SecondLevelTemplate}'/> <HierarchicalDataTemplate x:Key='SecondLevelTemplate' ItemTemplate='{StaticResource ThirdLevelTemplate}'/> <HierarchicalDataTemplate x:Key='ThirdLevelTemplate' ItemTemplate='{StaticResource FourthLevelTemplate}'/> <DataTemplate x:Key='FourthLevelTemplate'/> 

What property(ies) need to be set to display my data directly from a DataSet?

edit: Ideally, I’d like to do this using a single self-referencing DataTable.

  • 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. 2026-05-11T13:02:07+00:00Added an answer on May 11, 2026 at 1:02 pm

    I do not think you can do that.

    The Treeview control, and the HierarchicalDataTemplate expect a hierarchy of objects. The DataSet is inherently flat.

    You will have to somehow convert that dataset to a hierarchy of objects, each with its own ‘Children’ collection. The ItemsSource of the treeview will be bound to the ‘top level collection’ (the rows without a parent reference).

    Each HierarchicalDataTemplate will have its ItemsSource property bound to the corresponding Children property.

    There might be a solution using converters, but if it exists it would probably end up being more complicated than straight up reshaping the data before binding.

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

Sidebar

Related Questions

I have a DataSet consisting of XML data, I can easily output this to
I am retrieving data from a SQL table so I can display the result
I have IEnumerable that is result of database query that has a large dataset,
I have a sql query like this: if table1 exist if table1 has data
i have a sql query that can bring back a large number of rows
I have a dataset in MySQL where using limit is already an expensive query,
I have a DataSet populated from Excel Sheet. I wanted to use SQLBulk Copy
I have generated a dataset that contains data spanning thirty days. Im trying to
I want to bind the results of an SQL query to a Listbox of
I have a sequence of sql queries that result in very large datasets that

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.