Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3229316
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:47:48+00:00 2026-05-17T16:47:48+00:00

I’m SO close, but so far. I’ve got two tables, one for publication details,

  • 0

I’m SO close, but so far.
I’ve got two tables, one for publication details, the other for the categories adjacency list.

I’m trying to display the full dataset with nested repeaters (unless there’s a better way)
and I’m building my DataSet as shown:

string strSql = "SELECT category_id, parent_id, cat_name_en " +
                "FROM categories;" +
                "SELECT pub_id, title_en, category_id " +
                "FROM publications;";

SqlConnection conn = new SqlConnection(connString.ConnectionString);
SqlDataAdapter da = new SqlDataAdapter(strSql, conn);

DataSet _ds = new DataSet();   
da.Fill(_ds);
_ds.DataSetName = "categories";
_ds.Tables[0].TableName = "category";
_ds.Tables[1].TableName = "publications";

_ds.Relations.Add("ParentChild", 
                  _ds.Tables["category"].Columns["category_id"],
                  _ds.Tables["category"].Columns["parent_id"], false);
_ds.Relations[0].Nested = true;

_ds.Relations.Add("CategoryMembers", 
                  _ds.Tables["category"].Columns["category_id"],
                  _ds.Tables["publications"].Columns["category_id"], false);
_ds.Relations[1].Nested = true;


categoryRepeater.DataSource = _ds.Tables["category"];
categoryRepeater.DataBind();

I’m displaying the data like this:

<asp:Repeater runat="server" ID="categoryRepeater" EnableViewState="false">
  <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem, "category_id") %>
    <%# DataBinder.Eval(Container.DataItem, "cat_name_en") %><br />

    <asp:Repeater runat="server" EnableViewState="false"
      DataSource='<%# GetChildRelation(Container.DataItem, "CategoryMembers") %>'>  
      <ItemTemplate>
        <p><%# DataBinder.Eval(Container.DataItem, "pub_id") %>&nbsp;
           <%# DataBinder.Eval(Container.DataItem, "title_en") %></p>
      </ItemTemplate>
    </asp:Repeater>

    <asp:Repeater runat="server" EnableViewState="false" 
      DataSource='<%# GetChildRelation(Container.DataItem, "ParentChild") %>'>
      <ItemTemplate>
        <%# DataBinder.Eval(Container.DataItem, "category_id") %>
        <%# DataBinder.Eval(Container.DataItem, "cat_name_en") %><br />  
        <asp:Repeater runat="server" EnableViewState="false"
          DataSource='<%# GetChildRelation(Container.DataItem, "CategoryMembers") %>'>
          <ItemTemplate>
            <p><%# DataBinder.Eval(Container.DataItem, "pub_id") %>
               <%# DataBinder.Eval(Container.DataItem, "title_en") %></p> 
          </ItemTemplate>      
        </asp:Repeater>
      </ItemTemplate>    
    </asp:Repeater>
  </ItemTemplate>
</asp:Repeater>

I’ve nested the repeaters like that because some categories don’t have children categories, but still have publications.

So I’ve got the Relations in place to get any Children categories, and then get any publications belonging to that category.
I get the listing of categories with their children and any publications that belong to the category.

The problem is I can’t figure out how to prevent some of the Children categories being treated as Parents. There are some categories that do not have parents, but still have publications. These categories will be displayed correctly under their parent and then AGAIN as their own Parent category

How do I configure the tables or relations so children categories aren’t treated like parents?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:47:48+00:00Added an answer on May 17, 2026 at 4:47 pm

    First you’ll need to create a DataView with the RowFilter of either “parent_id is null” or parent_id = ” depending on what the data is

    Next bind that dataview instead of the table.

    e.g.

    DataView dv = new DataView(_ds.Tables["category"]);
    dv.RowFilter = "parent_id is null";
    
    categoryRepeater.DataSource = dv;
    

    You shouldn’t have to touch your GetChildRelation function as it will still get a DataRowView from Container.DataItem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.