Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATING PARENT CHILD NAVIGATION MENUS

Status
Not open for further replies.

mit99mh

Programmer
Sep 24, 2002
246
GB
I need to create a PARENT CHILD menu like the one illustrated below

INITIAL STATE:

PARENT 1
PARENT 2
PARENT 3
PARENT 4

PARENT 2 CLICKED

PARENT 1
PARENT 2
CHILD 1
CHILD 2
CHILD 3
PARENT 3
PARENT 4

I was going to do this using Code Behind and datagrids - is it possible to use datagrids in this manner?

Any help much appreciated.

 
i managed to get a solution for this see below any comments welcome:

CODEBEHIND:

Public Sub Page_Load(Sender As Object, E As EventArgs)
if not IsPostBack then
lblMessage.Text = "Portal Content Displayed"
' make connection show first data set
BindDataList(0)
end if
End Sub

'CAPTURE EVENTS WITH FOLLOWING METHODS
Public Sub DataList_ItemCommand( s as object, e as DataListCommandEventArgs )
dlstTitles.SelectedIndex = e.Item.ItemIndex
Dim intForumID As Integer
intForumID = dlstTitles.DataKeys( e.Item.ItemIndex )
lblMessage.Text = "ID " + intForumID.ToString()

BindDataList(intForumID)
end sub

Private Sub BindDataList( forumID As Integer )
Dim strConn as string = "server=147.149.226.14;uid=isdevelopment;pwd=656404;database=Northwind"
Dim MySQL as string = "Select CategoryID, CategoryName from Categories"
Dim MyConn as New SQLConnection(strConn)
Dim ds as DataSet=New DataSet()

Dim Cmd as New SQLDataAdapter(MySQL,MyConn)
Cmd.Fill(ds,"Categories")

Dim cmd2 As SqlDataAdapter = New SqlDataAdapter("select * from Products WHERE CategoryID = " + forumID.ToString(), MyConn)
cmd2.Fill(ds, "Products")

ds.Relations.Add("myrelation", ds.Tables("Categories").Columns("CategoryID"), ds.Tables("Products").Columns("CategoryID"))

dlstTitles.Datasource=ds.Tables("Categories").DefaultView
DataBind()

End Sub

aspx file:


<%@ Page Inherits=&quot;masterChild&quot; src=&quot;masterChild.aspx.vb&quot; %>
<html>
<body>
<form runat=&quot;server&quot;>
<asp:label id=&quot;lblMessage&quot; runat=&quot;server&quot; />

<hr>

<asp:DataList
id=&quot;dlstTitles&quot;
OnItemCommand=&quot;DataList_ItemCommand&quot;
DataKeyField=&quot;CategoryID&quot;
Runat=&quot;server&quot;>

<ItemTemplate>
<asp:LinkButton Text=<%# Container.DataItem(&quot;CategoryName&quot;) %> Runat=&quot;Server&quot;/>
<asp:DataList runat=&quot;server&quot;
Id=&quot;ChildDataList&quot;
GridLines=&quot;None&quot;
Bordercolor=&quot;black&quot;
cellpadding=&quot;3&quot;
cellspacing=&quot;0&quot;
Headerstyle-BackColor=&quot;#8080C0&quot;
Headerstyle-Font-Name=&quot;Arial&quot;
Headerstyle-Font-Size=&quot;8&quot;
Font-Name=&quot;Arial&quot;
Font-Size=&quot;8&quot;
datasource='<%# Container.DataItem.Row.GetChildRows(&quot;myrelation&quot;) %>'
RepeatColumns=&quot;1&quot;>
<ItemTemplate>
<asp:LinkButton Text=<%# Container.DataItem(&quot;ProductName&quot;) %> Runat=&quot;Server&quot;/>
</ItemTemplate>
</asp:DataList>
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top