Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I m working on a project where i want to build menu controls dynamically n it must contain d data from d database. I know how to bind database but d problem is i am nt able to align d menu controls in horizontal way. Please give me some quick responses.
Posted
Comments
Monjurul Habib 18-Jun-11 5:23am    
share your code to help you.

Please refer following code. e.g. if you have database structure having following fields.

SectionId, subSectionId, Title,subtitle, URL .. then following code will work...

dsList = objClsusr.GetUserLinks(empId)
dvList = dsList.Tables(0).DefaultView
dtList = dvList.ToTable("0", True, "SECTION_ID", "TITLE")
If dtList.Rows.Count > 0 Then
For index As Integer = 0 To dtList.Rows.Count - 1
Dim menuItm As New MenuItem
menuItm.Value = dtList.Rows(index)("TITLE")
menuItm.Text = dtList.Rows(index)("TITLE")
menuItm.NavigateUrl = "#"
menuItm.SeparatorImageUrl = ""
Menu.Items.Add(menuItm)
Dim dv As New DataView
With dv
.Table = dsList.Tables(0)
.RowFilter = " SECTION_ID=" & dtList.Rows(index)("SECTION_ID")
.RowStateFilter = DataViewRowState.CurrentRows
End With
For dvindex As Integer = 0 To dv.Count - 1
Dim childItm As New MenuItem
childItm.Text = dv.Item(dvindex)("SUBTITLE")
childItm.Value = dv.Item(dvindex)("SUBTITLE")
childItm.NavigateUrl = "javascript:onNodeClick('" + dv.Item(dvindex)("URL") + "');"
childItm.SeparatorImageUrl = "~/Images/menu-seprator.jpg"

Menu.FindItem(dtList.Rows(index("TITLE")).ChildItems.Add(childItm)


Next
'dv.Table.Clear()
Next
End If
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900