Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Nested Data Lists Problems

Reply
Thread Tools

Nested Data Lists Problems

 
 
Roberto Modica
Guest
Posts: n/a
 
      12-01-2003
Hi, i have a nested data list which is supposed to expand
a list of categories. e.g.

--Initial Set Of Categories
HOME
CAT A
CAT B
CAT C

--After CAT A Click
HOME
CAT A
- SUB CAT A
- SUB CAT B
CAT C
CAT D

I can get to this stage, although i do have to click the
links twice which is very strage (Any Ideas??) The next
stage is where i get problems:

--After SUB CAT A Click
HOME
CAT A
- SUB CAT A
- - - Sub Sub Cat A
- - - Sub Sub Cat B
- SUB CAT B
CAT C
CAT D

For some reason when i click on the first level expanded
list nothing happens, i do not get any errors, just
nothing happens. here is my code:

--default.aspx

<%@ page inherits="WebMenu" src="codebehind.vb"
AutoEventWireup="false"%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form runat="server">
<ASPataList DataKeyField="ID" id="grdCategories"
runat="server">
<ItemTemplate>
<asp:linkbutton id="selCategoryID" Text='<%
#DataBinder.Eval(Container.DataItem, "SiteCategoryName") %
>' CommandName="Select" class="SubHead" runat="server"/>

</ItemTemplate>
<SelectedItemTemplate>
<asp:linkbutton id="selCategoryID"
Text='<%#DataBinder.Eval
(Container.DataItem, "SiteCategoryName") %>'
CommandName="Select" class="SubHead" runat="server"/>
<ASPataList id="grdSubCat1"
DatKeyField="ID" runat="server" datasource= '<%
#Container.DataItem.CreateChildView("myrel") %>' >
<ItemTemplate>
<asp:linkbutton id="subcat1"
Text='<%# Container.DataItem("SiteCategoryName") %>'
CommandName="Select" class="SubHead" runat="server"/>
</ItemTemplate>
<SelectedItemTemplate>
<asp:linkbutton
id="subcat1" Text='<%# Container.DataItem
("SiteCategoryName") %>' CommandName="Select"
class="SubHead" runat="server"/>
<ASPataList
id="grdSubCat2" runat="server" DataKeyField="ID"
datasource= '<%# Container.DataItem.CreateChildView
("myRel") %>' >
<ItemTemplate>

<asp:linkbutton id="subcat2" Text='<%#
Container.DataItem("SiteCategoryName") %>'
CommandName="Select" class="SubHead" runat="server"/>
</ItemTemplate>
</ASPataList>
</SelectedItemTemplate>
</ASPataList>
</SelectedItemTemplate>
</ASPataList>
</form>
</body>
</html>

-_Codebehind.vb

'Import Required Name Spaces
Imports System
Imports System.Data
Imports System.Data.SQLClient
Imports System.Web.UI.WebControls
Imports System.Web.UI

Public Class WebMenu
Inherits Page

'Declare Class Variables
'Dim CategoryID As Integer
Dim ParentID As Integer
Dim SubParentID As Integer

'Declare Corrosponding Page Elements **REQUIRED**
Dim Protected WithEvents grdCategories As DataList
Dim Protected WithEvents grdSubCat1 As DataList
Dim Protected WithEvents grdSubCat2 As DataList
Dim Protected WithEvents grdSubCat3 As DataList

Private Sub Page_Load(byVal sender As Object,
byVal e as EventArgs) Handles MyBase.Load

'IF NOT isPostback THEN
'Bind The Data List
'BindDataList()

'END IF

'Declare Connection Vars
Dim MyConn As String
= "server=WIN2KSERVER;uid=sa;pwd=;database=ENUTZ DEV"
Dim MyConnection As New SqlConnection
(MyConn)

'Declare SQL Statment Vars
Dim SQL As String
Dim SQL1 As String
Dim SQL2 As String

'Create SQL Adapters
Dim cmd As SqlDataAdapter
Dim cmd1 As SqlDataAdapter
Dim cmd2 As SqlDataAdapter

'Declare Dataset to store our related
tables
Dim ds As DataSet = New DataSet

'Set First SQL Statement And Fill DataSet
SQL = "SELECT * FROM tblSiteCategories
WHERE SiteCategoryParent = 0"
cmd = New SqlDataAdapter(SQL,
MyConnection)
cmd.Fill(ds, "MainCat")

'Set Second SQL Statement And Fill DataSet
SQL1 = "SELECT * FROM tblSiteCategories
WHERE SiteCategoryLevel = 1"
cmd1 = New SqlDataAdapter(SQL1,
MyConnection)
cmd1.Fill(ds, "FirstLevel")

'Set Third And Final SQL Statement And
Fill DataSet
SQL2 = "SELECT * FROM tblSiteCategories
WHERE SiteCategoryLevel = 2"
cmd2 = New SqlDataAdapter(SQL2,
MyConnection)
cmd2.Fill(ds, "SecondLevel")

'Create Relationships
ds.Relations.Add("myRel", ds.Tables
("MainCat").Columns("ID"), ds.Tables("FirstLevel").Columns
("SiteCategoryParent"))
ds.Relations.Add("myChildRel", ds.Tables
("FirstLevel").Columns("ID"), ds.Tables
("SecondLevel").Columns("SiteCategoryParent"))

'Bind Data
grdCategories.Datasource=ds.Tables
("MainCat").DefaultView
DataBind()

End Sub



End Class

I am new to ASP.NET so go easy on me.

Thank you

Roberto
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
List of lists of lists of lists... =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==?= Python 5 05-15-2006 11:47 AM
lists of lists Jon Slaughter C++ 4 12-13-2004 06:28 PM
Lists of Lists VWWall Computer Information 2 10-21-2004 01:15 AM
Counter for items in lists in lists? Charlotte Henkle Python 8 09-26-2004 04:22 AM
Sorting lists of lists... JustSomeGuy C++ 0 06-17-2004 05:44 PM



Advertisments