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

  • Home
  • SEARCH
  • 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 4022204
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:26:47+00:00 2026-05-20T10:26:47+00:00

C# through ASP.Net 2.0. In a datatable I have two columns of IDs, attributeId

  • 0

C# through ASP.Net 2.0.

In a datatable I have two columns of IDs, attributeId and productAttributeID.

I want to loop through this table and ‘group’ them in such a way that productAttributeIds have one or more attributeIds associated with them.

For example, in pseudo-code this is what I’m doing

For each datarow in myDatatable.rows

Insert into myarray at index(productattributeId) - corresponding attributeId

end foreach

So this will loop and each time the same productAttributeId is present, the attributeId will be added to the array corresponding.

Obviously this won’t work as arrays need to be size declared etc.

I’ve tried multi-dimensional arrays, jagged arrays, arraylists, lists of arraylists all to no avail, my code is failing yet I know in theory what I want to do.

  • 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-20T10:26:48+00:00Added an answer on May 20, 2026 at 10:26 am

    I would, personally, use a Dictionary<int, List<int>>:

    foreach(var row in data)
    {
        // Get your data...
        int attributeId = GetAttributeId();
        int productAttributeId = GetProductAttributeId();
    
        List<int> attributes;
        if(!dictionary.TryGetValue(productAttributeId, out attributes)
        {
           attributes = new List<int>();
           dictionary[productAttributeId] = attributes;
        }
        attributes.Add(attributeId);
    }
    

    You can then easily get all of the product attributes for an attribute:

    List<int> attributeIds = dictionary[productAttributeId];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an API consisting of ASP.NET webservices callable through GET/POST/SOAP. A new functionality
I am running ASP.NET MVC Beta. I have an AJAX call running through jQuery
In C#/ASP.NET 3.5, I have a DataTable which pulls rows from the database. I
I have 2 datatables in my ASP.NET application. I loop though both of them,
Can I setup a custom MIME type through ASP.NET or some .NET code? I
I just downloaded the ASP.NET MVC beta and wanted to walk through the quickstarts
Having not done ASP.NET since v1.1, and now blitzing through the Wrox Pro ASP.NET
I'm trying to run powershell commands through a web interface (ASP.NET/C#) in order to
I am trying to go through the following tutorial on asp.net. When I get
Has anybody gone through the process of converting a real-world business application from ASP.NET

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.