Go From A Datatable To Hierarchical Structure?

Feb 22, 2011

I have a datatable which i get from the databasemanager class, and i would need to transform that data into a hierarchical structure

either binding it directly to a .net treeview control or in memory first .

i have an ID column, and a ParentID column.what i do not know necessarily is the parent ID to start with. so first thing to do would be to find out which node is the parent ID.

what would be best practice to loop over this table and make it hierarchical

BranchId ParentId ProductCount HasBranchChildren Name
0 NULL 48 1 Categories
1 0 20 1 CategoryA
2 1 10 1 CategoryA1
3 1 8 0 CategoryA2
4 1 2 0 CategoryA3
5 2 4 0 CategoryA1.1
6 2 6 0 CategoryA1.2
7 0 28 1 CategoryB
8 7 20 0 CategoryB1
9 7 8 0 CategoryB2

this would be an example datatable of course it will have hundreds of items, and it does not always start at the root node, its possible that with a request a certain subset of categories is requested, however i've talked with the database team and they will give me NULL on root nodes in the above example that would be element 0 in the table ....

View 2 Replies


Similar Messages:

Web Forms :: Hierarchical Structure Within A List Box?

Sep 15, 2010

i added a collection of data into a list box. i have another group of data with a group name.i want to add this group in to that same list box as a tree structure.

the sample list box is shown below.

item1
item2
item3
-group name
group item1
gruop item 2
gruop item 3
item 4
item 5

is there any way to do this. when clicking on the group name it must be expanded within the list box and i want to manage all these elements with an index.

View 3 Replies

DataSource Controls :: How To Display Hierarchical Structure In A Data Control

Mar 19, 2010

i have a table with parent-child relationship wherein each child in turn can have multiple associated children. i want to display data in an hierarchical way with collapse and expand features.i dont want to use 'listview inside a listview inside a listview' approach. and yes i have googled it but cudnot find anything useful for my scenario. has someone successfully tried implementing this ?

View 4 Replies

Creating DataTable Structure With MySQL DateTime

Dec 29, 2011

I am setting up a routine whereby I have to copy the results of a MySQL stored procedure into a DataTable so that I can add fields to the end of the result.

Normally I would convert the Msql DateTime to something that I could more easily manipulate; however, the existing code that I have specifically addresses the MySql DateTime type in too many ways to easily change.

So I thought I could do something like this:

Code:
myDataColumn = new DataColumn("ETD_DT");
myDataColumn.DataType = System.Type.GetType("System.DateTime");
returnDataTable.Columns.Add(myDataColumn);

And substitute "MySqlData.Types.MySqlDateTime" for "SystemDateTime", but it fails with "Column Requires a Valid DataType".

View 2 Replies

Error "DataTable Is An Ambiguous Reference Between System.Data.DataTable And Microsoft.Office.Interop.Word.DataTable"

Jan 20, 2011

'DataTable' is an ambiguous reference between 'System.Data.DataTable' and 'Microsoft.Office.Interop.Word.DataTable'

View 3 Replies

Asp - Editing Hierarchical Data

Aug 13, 2010

I just finished making a change to an ASP.NET Ajax screen from a few years back. It was harder than expected to build and maintain. On this change, I estimated 12 hours and spent 4 days. Granted I also did extensive refactoring to simplify the code. This is actually some pretty fun code, but I wonder if there was a better route for the original implementation than the one I took. To start, here's a screenshot:

The Problem So obviously this is an editable tree of data. The data behaves very differently at each level -- very different sorting/collision rules and so on. My solution is actually performant and provides an adequate user experience, but it's nearly 2,000 lines of code spanning 11 classes, which is more than I envisioned going in. I'm curious if you've solved similiar problems and if you were able to find a simpler solution. It looks pretty straightforward at a glance, maybe that means I did something right. But there is some real complexity here -- obviously you can add and remove items at three different levels, and everything sorts similiar to a netflix queue, but with quirks. It also has to detect collisions on the various entities (in the image, if you changed day 5 to day 1, it would have to figure out which one is actually day one and move the other one).

The biggest problem was keeping track of the state, since users don't want to commit changes to the database as they work. I thought it might be possible to use the actual controls (nested repeaters in this case) to represent this interim state, but that ended up being a dead end due to complexities related to the underlying data. The Solution To solve this, I created a full blown XML representation of all the data, which was actually great in some ways since I was able to use LINQ to do a lot of heavy lifting around sorting and querying. Still, there is a lot of code in here related to syncing up the xml to the html and so on, and I had to make a pretty hefty abstraction on top of the xml to make it easy for me to work with it in code. In case you're interested, I am currently persisting the XML to session state so that it will survive across callbacks, but eventually that should go into the database.

One colleague told me it would be better to use Flex or maybe Silveright for something like this, and I think that might be true since those are both much more stateful, although Silverlight was not ready for prime time back when this started, and I don't know Flex. Maybe using a temp table instead of xml would have been superior in some way. I'm looking to learn and improve -- what have your experiences been with this type of problem?

View 1 Replies

C# - Best Method To Search Hierarchical Data?

Mar 15, 2010

I'm looking at building a facility which allows querying for data with hierarchical filtering. I have a few ideas how I'm going to go about it but was wondering if there are any recommendations or suggestions that might be more efficient.

As an example imagine that a user is searching for a job. The job areas would be as follows.

1: Scotland
2: --- West Central
3: ------ Glasgow
4: ------ Etc
5: --- North East
6: ------ Ayrshire
7: ------ Etc

A user can search specific (i.e. Glasgow) or in a larger area (i.e. Scotland).

The two approaches I am considering are:

keep a note of children in the database for each record (i.e. cat 1 would have 2, 3, 4 in its children field) and query against that record with a SELECT * FROM Jobs WHERE Category IN Areas.childrenField.
Use a recursive function to find all results who have a relation to the selected area.

The problems I see from both are:

Holding this data in the db will mean having to keep track of all changes to structure.
Recursion is slow and inefficent.

I'm using C# ASP.NET with MSSQL 2005 DB.

View 5 Replies

MVC :: Generate Hierarchical Menu From Database?

Mar 2, 2011

Site.Master file contains

<ul id="nav">
<% Html.RenderAction("Menu", "ShoppingCart"); %>
</ul>
[ChildActionOnly]
public ActionResult Menu()
{
// for to geenrate menu ?
return ????
}

How to generate hierarchical menu below in Menu method from database data ? Should I use stringbuilder or is there better way ?

Resulting html shoudl look like:

[Code]....

View 64 Replies

C# - Three Level Hierarchical Data-linq?

May 7, 2010

I have three level hierarchical data. using the statement below i managed to display two level data. I need to extend it to one more level.

Current hierachy is Modules-->Documents

I need to extend it as Packages-->Modules-->Documents

var data = (from m in DataContext.SysModules join d in DataContext.SysDocuments on m.ModuleID equals d.ModuleID into tempDocs from SysDocument in tempDocs.DefaultIfEmpty()
group SysDocument by m).ToList();

View 2 Replies

.net - Show Hierarchical Data In A Dropdownlist?

Mar 21, 2010

I have a table in SQL Server 2005.

I want to show all domain name in a dropdownlist maintaing the same hierarchy. i.e

Law
Engineering
--civil
--Mechanical
Medical
--Dental
----Cavity
--MBBS

I need to append '--' according to the domain level. Is it possible using a sql query. or alternatively can I have any other control to show this data.

View 3 Replies

MVC :: Hierarchical Component Architecture Incompatible?

Nov 17, 2010

I'm building an ASP.Net MVC 2 application with a component architecture. There are two different types of components: Elementary Components, which have an associated controller action rendering a partial view, and Layout Components, which render all their child components (Elementary Components or again Layouts) in a certain layout.Here is my generic RenderComponent() action method, which takes a component ID and renders the appropriate view:

[Code]....

Is my hierarchical component architecture incompatible with ASP.Net MVC? How would you build such a system in ASP.Net MVC?

View 1 Replies

Web Forms :: How To Display Hierarchical Data In Checkboxlist

Jan 19, 2010

how to display hierarchical data in checkboxlist

View 6 Replies

Hierarchical SQL Roles Based On Default RoleProvider

Feb 11, 2011

I'm trying to implement the following adjustments to the default ASP.NET RoleProvider so that it supports hierarchical role definitions. However i cannot create the following function, it keeps Executing the function.

Ref: [URL]

What is wrong with this function?

-- Template generated from Template Explorer using:
-- Create Multi-Statement Function (New Menu).SQL
--
-- Use the Specify Values for Template Parameters
-- command (Ctrl-Shift-M) to fill in the parameter
-- values below.
--
-- This block of comments will not be included in
-- the definition of the function.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
CREATE FUNCTION [dbo].[aspnet_Roles_Ancestor_TVF] (
@RoleId uniqueidentifier
)
RETURNS
@aspnet_Roles TABLE (
ApplicationId uniqueidentifier
, RoleId uniqueidentifier
, RoleName nvarchar(256)
, LoweredRoleName nvarchar(256)
, Description nvarchar(256)
, ParentRoleId uniqueidentifier
)
AS
BEGIN
; WITH aspnet_Roles_CTE (
ApplicationId
, RoleId
, RoleName
, LoweredRoleName
, Description
, ParentRoleId
, HierarchyLevel
) AS (

[Code.....]

View 2 Replies

AJAX :: Selection Tool For Hierarchical Dimension

Mar 24, 2011

We are trying to design selection tool for a hierarchical dimension (e.g. org-dept-subdept) in order to query SSAS cube. When user clicks a drop down list, a tree view will pop out for user to select single or multi tree nodes. Ideally it would be like the drop down box used in Excel pivot table when it is connecting to a SSAS cube. If there is any Ajax control that can perform similar function

View 1 Replies

Hierarchical Menu Populated From Sqlserver Table?

May 13, 2010

Hierarchical menu populated from sqlserver table?

View 2 Replies

C# - Build Hierarchical Html List From Dataset?

Sep 14, 2010

I am getting following output in Dataset

ActivityID ParentActivityID ActivityName AcivityLevel
0 NULL Dashboard 0
1 NULL Market Trends 0
2 1 News 1

and I want to build HTML list as follow.

<ul>
<li>Dashboard</li>
<li>Market Trends[code]....

View 1 Replies

C# - IHierarchicalEnumerable The Prefered Way Of Dealing With Hierarchical Data?

Dec 14, 2010

I'm building an asp.net mvc app, I want to build up an hierarchical structure, is IHierarchicalEnumerable and IHierarchyData the best way to implement a hierarchical structure?

View 1 Replies

C# - How To Build A Self-referencing Model Object For Hierarchical Data In MVC

Sep 9, 2010

I'm trying to understand how to build a self referencing model for hierachical data. Eventually i will be creating a category tree.

I don't anything in tables yet. After I have the structure nailed down then I will create the tables. My existing Object is defined like this:

public class Categories

[Code]....

View 1 Replies

Hierarchical - Multi Select Controls That Use Check Boxes In C#?

Mar 24, 2010

I need to be able to select multiple options on a web form, but those options are hierarchical. For example:

Option 1
Option 1 a
Option 1 b
Option 2

The user should be able to select Option 1, or Option 1a, etc. Selecting Option 1 a should automatically select Option 1.

View 2 Replies

Persisting State On A Master Page's Hierarchical List?

Feb 17, 2010

I'm writing an ASP.Net application (no AJAX, but maybe) and there's a requirement to have a list of companies graded under a traffic light system. I intend to have these in a collapsible hierarchical list on the Master page, e.g. Red expands to show companies, and then companies can be further expanded.

how can I keep the expanded list in the same place, with the same content visible, between page loads?

View 1 Replies

Forms Data Controls :: 3.5 Tabular DataList Hierarchical?

May 20, 2010

I want to learn how to show html in a situation of a tabular format to One To Manyto make me understand I have the categories and subcategories for each category I wish we were all subcategories.I tried with a DataList, but the categories repeated for each subcategoryIs there a way to do it. For example in asp.net mvc I wrote everything in aspx page

View 3 Replies

C# - Url Routing From Hierarchical Tree Of Pages Stored In A Database?

Mar 2, 2010

I have a bunch of html pages stored in a mssql database. Each row has:

ID
PageTitle
Page Html Content
ParentId

ParentId is there so i can create a hierarchical tree of pages.

Currently i am using this line of code in order to access the pages...

routes.MapPageRoute("front", "{PageTitle}", "~/front.aspx");

Which then causes a redirect to front.aspx so i can then use:

Page.RouteData.Values["PageTitle"].ToString()

In order to grab what i need so i can display the appropriate page in the browser.

However, can anyone suggest how i would amend 'routes.MapPageRoute' so it supports an infinate hierarchical tree like i have in my database. Essentially i want to be able to type a url like: http://localhost/PageOne/SubPageOfPageOne etc

View 1 Replies

Forms Data Controls :: Create Hierarchical Grid Using C#?

Dec 13, 2010

how to create hierarchical grid using c#

View 1 Replies

Web Forms :: Can Read From A Dataset And Create A Hierarchical Horizontal Menu

Mar 5, 2010

Can I read from a dataset and create a hierarchical horizontal menu?

View 4 Replies

Forms Data Controls :: How To Create Hierarchical-master / Detail UI

Aug 11, 2010

So here is the situation - there is data on master records - its a hierarhical view - something like (ID, IDParent, Title) and detail data - (ID, IDMaster, Details)

And like to build UI using an TreeView - binded with master data - and an GridView - binded with detail data.

Question is witch property to use to create the master/detail chain between Datasources - oh, I've forgot to tell I'm using an ObjectDataSource?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved