I know i can bind to Self-Related Data in the WebHierarchicalDataGrid, but is it possible to do in the WebDataMenu?
Here's the Data Structure I have...
ID PARENT URL NAME
1 NULL <url> SomeName
2 NULL <url> SomeName
3 NULL <url> SomeName
30 3 <url> SomeName
31 3 <url> SomeName
4 NULL <url> SomeName
And so on...
Is there an easy way to set up binding for this in the WebDataMenu?
I have another way of formatting the data (which I'll ask in a separate question)
Hello,
You can achieve your task using the WebHierarchicalDataSource. Please take a look at the attached sample page.
Here is what I did to acomplish this task:
1. Created a SQL Server self related table:
CREATE TABLE [dbo].[SelfRelatedData]( [Id] [int] NOT NULL, [ParentId] [int] NULL, [Text] [nvarchar](128) NULL, [NavigateUrl] [nvarchar](512) NULL, CONSTRAINT [PK_SelfRelatedData] PRIMARY KEY CLUSTERED ([Id] ASC)) ON [PRIMARY]GOINSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (1, NULL, N'File', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (2, NULL, N'Edit', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (3, NULL, N'Help', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (4, 1, N'Open', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (5, 1, N'New', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (6, 1, N'Close', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (7, 1, N'Exit', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (8, 2, N'Cut', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (9, 2, N'Copy', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (10, 2, N'Paste', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (11, 3, N'Online Help', NULL)INSERT [dbo].[SelfRelatedData] ([Id], [ParentId], [Text], [NavigateUrl]) VALUES (12, 3, N'About', NULL)GOALTER TABLE [dbo].[SelfRelatedData] ADD CONSTRAINT [FK_SelfRelatedData_SelfRelatedData] FOREIGN KEY([ParentId]) REFERENCES [dbo].[SelfRelatedData] ([Id])GO
2. Created 2 SQL Data Source control on the page (1 that takes only root data, and 1 that takes all the data)
3. Created WebHeirarchicalDataSource and convigured its views properly to use the 2 SQL DataSources
4. Created WebDataMenu that is bound to the WebHierarchicalDataSource, and set its DataMenuItemBinding settings accordingly:
Hope this helps!
14: <ig:WebDataMenu runat="server" ID="wdMain" DataSourceID="WebHierarchicalDataSource">
15: <DataBindings>
16: <ig:DataMenuItemBinding DataMember="vRoot" TextField="Text" NavigateUrlFields="NavigateUrl" />
17: <ig:DataMenuItemBinding DataMember="vChild" TextField="Text" NavigateUrlFields="NavigateUrl" />
18: </DataBindings>
19: </ig:WebDataMenu>
26: <ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource" runat="server">
27: <DataViews>
28: <ig:DataView ID="vRoot"
29: DataSourceID="SqlDsSelfRelatedDataRoot" />
30: <ig:DataView ID="vChild"
31: DataSourceID="SqlDsSelfRelatedDataChild" />
32: </DataViews>
33: <DataRelations>
34: <ig:DataRelation ParentDataViewID="vRoot"
35: ParentColumns="Id" ChildDataViewID="vChild"
36: ChildColumns="ParentId" />
37: </DataRelations>
38: </ig:WebHierarchicalDataSource>
20: <asp:SqlDataSource ID="SqlDsSelfRelatedDataRoot" runat="server"
21: ConnectionString=" <% $ ConnectionStrings:IGDemosConnectionString %> "
22: SelectCommand="SELECT * FROM [SelfRelatedData] WHERE ParentId IS NULL"></asp:SqlDataSource>
23: <asp:SqlDataSource ID="SqlDsSelfRelatedDataChild" runat="server"
24: ConnectionString=" <% $ ConnectionStrings:IGDemosConnectionString %> "
25: SelectCommand="SELECT * FROM [SelfRelatedData]"></asp:SqlDataSource>
Hi Anton,
This is a good example to bind a Datamenu with SQL Table. However my problem is what if we want to display multi tier menu. If we consider this example than i want to display menu like File>>New>>New One>>New Two. How can we set up this kind of format?
Thanks,
Mits