Hello,
I am finding myself a bit confused as to the best way to bind a control (DataList) to data pulled from a table that has a built-in hierarchy via a self-referencing foreign key relationship. I am using 2.0 adapter model.
The table as a foreign key pointing from ParentGUID to the RowGUID PK of the table.
Table structure:
CREATE TABLE [dbo].[Communities](
[RowGUID] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[ParentGUID] [uniqueidentifier] NULL,
CONSTRAINT [PK_Communities] PRIMARY KEY CLUSTERED
(
[RowGUID] ASC
)) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Communities] WITH CHECK ADD CONSTRAINT [FK_Communities_Communities]
FOREIGN KEY([ParentGUID]) REFERENCES [dbo].[Communities] ([RowGUID])
What’s the best way to bind to this data so that the hierarchical relationship is displayed like this:
Parent 1
- Child 1.1
- Child 1.2
Parent 2
- Child 2.1
- Child 2.2
This is the best article that I could find on the subject:
http://msdn2.microsoft.com/en-us/library/aa478959.aspx
In short, it says that I need to create relationships between the tables loaded in a DataSet then use nested DataBinders.
There must be a better way with LLBLGen.
In my case, the data is slowly changing and read only. Using a typed list seems like the best approach.
Am I heading down the right route? What’s the best way to accomplish this?
Thank you,
Rick