Dynamic DataList from a Dataset

 I am new to the ASP.NET, C#.
My problem description is that I have to create a Glossary web page. The Glossary will have some major categories. Each major category will have different levels of sub-categoires.
Finally, the lowest level sub-categories will be linked to a Term table where the users will be provided with the term, definition. example use etc.

I would like to create a main datalist for the major categories. I would like LinkButton the categories. Depending on what the user clicks, it will bring the subcategories........finally once there is no more subcategories, it will bring the Term related data sources.

Can somebody please provide me with some insight as to how I should proceed with the problem from an abstract level. I will then collaborate/continue to explore the solution.


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You will need to catch the selected index change of each dropdownlist.  Store the selected value, and the postback.  This will continue to drill down after the link, etc until you get to the bottom level.  Are you planning on doing this in a datagrid, datalist, etc or are you creating individual controls?


By abstract, conceptually, do you refer only to the presentation layer, or to the whole process, including data retrieval?

Just for illustration, I'll assume a table with three columns, where the first column has the categories, the second has the subcategories, and the third has the terms.

One way to go about it is to use three data repeaters in a table.  The table is only for positioning in this case, and not for the data itself.

      <asp:DataRepeater id="CatRepeater" runat="server">
            <asp:LinkButton id="CatLink" runat="server"></asp:LinkButton>
      <asp:DataRepeater id="SubRepeater" runat="server">
            <asp:LinkButton id="SubLink" runat="server"></asp:LinkButton>
      <asp:DataRepeater id="TermRepeater" runat="server">
            <asp:LinkButton id="TermLink" runat="server"></asp:LinkButton>

And provide a label for the definition.

<asp:Label id="Definition" runat="server"></asp:Label>

Because you may not want to limit the user to haveing to go through all the different levels, it may make sense to work a querystring system, instead of a post back system.  This way, a user can link to a definition or a subcategory directly.

So you check the querystring in your Page_Load method, and based on that info choose which DataRepeaters to bind to data, and also which data to access.  For example, say you decide on a querystring format like this:
MyPage.aspx?cat={category id}&sub={sub-category id}&term={term id}
In Page_Load you can do something like this:

... Page_Load(...)
' always bind the categories, because the user sees them no matter what
CatRepeater.DataSource = GetCategoryDataSource()

' then get the category querystring
Dim qsCat = Request.QueryString("cat")
if not qsCat is nothing and not qsCat = String.Empty then
  SubRepeater.DataSource = GetSubCategoryDataSource( Convert.ToInt32( qsCat ))

  ' only if there's a subcategory can there be a terms list
  Dim qsSub = Request.QueryString("sub")
  ' same logic for the subcategory
  if not qsSub is nothing and not qsSub = String.Empty then
    TermRepeater.DataSource = GetTermDataSource( Convert.ToInt32( qsSub ))

    ' only if there's a term can there be a definition
    Dim qsTerm = Request.QueryString("term")
    ' same logic for the term
    if not qsTerm is nothing and not qsTerm = String.Empty then
      Definition.Text = GetDefinition( Convert.ToInt32( qsTerm ))
    end if
  end if
end if
end sub

Because lots of this data seems to be relatively constant, you cache the inital category list, or use page caching (I won't go into that here right now).
Getting the various data sources is a matter of retrieving lists from the database based on a "parent".  Essentially, this seems like a very simple data structure:

NodeID int
ParentID int (root categories have a null parentid)
Text string (nvarchar?)
optionally also a Type int field which designates "category", "subcategory", "term" or "definition".
You may want to put definitions in a separate table.

In any case, accessing any list can be done with a single query (stored procedure, preferably) - assuming SQL Server:
create procedure GetChildren
@ParentID int = null
select NodeID, Text
from TreeTable
where ParentID = @ParentID

Then your Get...DataSource() functions all call the same procedure to retrieve the data and bind it to the correct level of DataRepeater.

Let me know if this is clear.  It should give you a direction, even you don't go for this exactly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_EsamAuthor Commented:
Hi shovavnik,
Your explanation was very clear to me pertaining to the fact of assuming that I used VB and SQL server along with ASP.NET provided with the table structure as you described.
But I am constraint to using the ASP.NET with C# and OleDb (MS Access).
Please find below a detailed explanation of what I have at this moment for the problem and what I need to do.
For the moment, my class project member created three tables for the Glossary database.
They are: Category, Term, Category_Term (the link table for Category and Term)
Below is the structure of the

Category table:

Category_ID            Category                  Parent_ID
100                  Applications            0
101                  Usability                  0
102                  Algorithms                  0
103                  Guideline of usability            101
104                  Bloopers                  101
105                  User analysis            103
106                  Task analysis            103
107                  User characteristics            105
108                  User Demographics            105

Term table:


Category_Term table:

Category_ID (references Category_ID in Category table)
Term_ID (references Term_ID in Term table)      

As you can see from the Category table, a subcategory was defined in terms of parent ids.
Major categories can have different levels of subcategories. Also it is possible that term(s) can be at any sublevels (in multiple sublevels of a category….I can defer this part for future extension of the project). A term is related via the category ids.

I am totally open to restructure the table if it can fulfill the following criteria.

I should be able to list all the major categories at the start of the page like the following:



Once the user clicks the Usability, the user will see the following list.


Guidelines of usability

Once the user clicks the Guidelines of usability, the user will see the following:


Guidelines of usability


User analysis
Task analysis

And so on…. A maximum of 7 levels (as requested)

Once the user reaches the lowest level of a category/subcategory, the user will find the term and their associated information relating the Term table.

It might be desirable from a professional point of view to show a navigational link like….



Guidelines of usability>User analysis>User demographics



Instead of the format described earlier.

I am totally open to any suggestion that might direct the project to a successful completion.

I personally would like to use DataList or Repeaters for displaying the information with
C#.NET and OleDb (MS Access).

I need definite help on figuring out how I can capture the event from the user from the datalist/repeater and redirect the user to proper information display at proper stages. I lack proficiency in this area.

Any advice of the query would also be appreciated.
I have a tentative query that needs to identify the category id. How I do that?

Please advise me with your expertise.


Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

_EsamAuthor Commented:
Note to participant experts.

Please note my intention of a request to the community support to delete this message.
I intend to provide a concrete example that will lead to a proper solution. Please note that there is no need to collaborate on this question anymore.

_EsamAuthor Commented:
Although I requested to close this question,
I am making a request to reward "shovavnik" some points for solid efforts.

_EsamAuthor Commented:
My sincere apology for not describing the problem statement of this question concisely.
I am brand new to the ASP.NET development.
I was expecting the answer to be in C#.
But the answer from "shovavnik" finally shed some light on my problem question.
I finally understood the problem in C# contex.
But I had to do some extensive research on this topic.
I believe it is best in my interest to reward "shovavnik" the full points.
I am making a request to do that.
But I still need to have this question closed.
Sorry for any inconveniences on this regard.

Thanks to shovavnik.


Thanks for the points.

I used to give example in c#, but found that most people who don't state the language they're using generally use vb.  I missed the part in your question where you stated c#.  So I apologize.

I'm glad my advice helped you anyway.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.