My issue is that I want to display data in a hierarchal structure as so:
- Democrat
- County Clerk
- Candidate 1
- Candidate 2
- Magistrate
- Candidate 1
- Candidate 2
- Candidate 3
- County Clerk
But I’m retrieving the dataset like this:
Party | Office | Candidate
--------------------------------------------
Democrat | County Clerk | Candidate 1
Democrat | County Clerk | Candidate 2
Democrat | Magistrate | Candidate 1
Democrat | Magistrate | Candidate 2
Democrat | Magistrate | Candidate 3
I planned on using nested repeaters, but I need a distinct value of Party, and then distinct values of office name within that party in order to do it.
Are there any .NET functions to easily do what I’m attempting to? Would there be a better way of displaying the information other than repeaters?
Thanks in advance!
If you can modify the stored procedure, I would recommend a result set in the form of an adjacency list:
It reduces the amount of data retrieved, and allows you to program recursively against the parent-child relationships. You simply start at the root. This approach avoids the hassle of using nested Repeaters by directly building the string literal in a StringBuilder.