Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Grouping Data in Dataset

Posted on 2008-06-12
1
Medium Priority
?
207 Views
Last Modified: 2008-06-18
Hello all.  I am currently trying to use a repeater but open to other options.  I have a dataset that looks like the following attached code I have a static dataset I am showing here.   I need the data to group by ProjectID and show the Description and then below the records but also by PurchaseType in seperate repeaters or datalist etc. such as:

Title: Oh snap I found a squirrel
Purchase Date   OrderNumber   Amount
03/10/2008        00179               150.00
03/08/2008        00180                 25.00
....
Title: Questions and Answers on Life Insurance
Purchase Date  OrderNumber   Amount
03/06/2008       00182             2010.95
.....

any help on best way to split this up?  I have a repeater but because I have one dataset I am having trouble creating the relation and distinct off projectid.  Not sure it is the best way but need some help.
protected static DataSet MainDataSet()
    {
        DataSet ds;
        System.Data.DataTable dt;
 
        ds = new DataSet();
        dt = new DataTable();
 
        // Columns
        DataColumn ProjectID;
        DataColumn Description;
        DataColumn PurchaseDate;
        DataColumn PurchaseType;
        DataColumn OrderNumber;
        DataColumn Amount;
 
        // Initialize the columns
        ProjectID = new DataColumn("ProjectID");
        Description = new DataColumn("Description");
        PurchaseDate = new DataColumn("PurchaseDate");
        PurchaseType = new DataColumn("PurchaseType");
        OrderNumber = new DataColumn("OrderNumber");
        Amount = new DataColumn("Amount");
 
        // Add columns
        dt.Columns.Add(ProjectID);
        dt.Columns.Add(Description);
        dt.Columns.Add(PurchaseDate);
        dt.Columns.Add(PurchaseType);
        dt.Columns.Add(OrderNumber);
        dt.Columns.Add(Amount);
 
        //Add DataRows to DataTable
        DataRow myRow;
        myRow = dt.NewRow();
        myRow["ProjectID"] = "22";
        myRow["Description"] = "Oh snap I found a squirrel";
        myRow["PurchaseDate"] = "03/10/2008";
        myRow["PurchaseType"] = "Book";
        myRow["OrderNumber"] = "000179";
        myRow["Amount"] = "150.00";
        dt.Rows.Add(myRow);
 
        myRow = dt.NewRow();
        myRow["ProjectID"] = "22";
        myRow["Description"] = "Oh snap I found a squirrel";
        myRow["PurchaseDate"] = "03/08/2008";
        myRow["PurchaseType"] = "Book";
        myRow["OrderNumber"] = "000180";
        myRow["Amount"] = "25.00";
        dt.Rows.Add(myRow);
 
        myRow = dt.NewRow();
        myRow["ProjectID"] = "22";
        myRow["Description"] = "Oh snap I found a squirrel";
        myRow["PurchaseDate"] = "03/07/2008";
        myRow["PurchaseType"] = "Book";
        myRow["OrderNumber"] = "000181";
        myRow["Amount"] = "85.00";
        dt.Rows.Add(myRow);
 
        myRow = dt.NewRow();
        myRow["ProjectID"] = "33";
        myRow["Description"] = "Questions and Answers on Life Insurance";
        myRow["PurchaseDate"] = "03/06/2008";
        myRow["PurchaseType"] = "Book";
        myRow["OrderNumber"] = "000182";
        myRow["Amount"] = "2010.95";
        dt.Rows.Add(myRow);
 
        myRow = dt.NewRow();
        myRow["ProjectID"] = "44";
        myRow["Description"] = "Cover Redesign";
        myRow["PurchaseDate"] = "03/10/2008";
        myRow["PurchaseType"] = "Service";
        myRow["OrderNumber"] = "000183";
        myRow["Amount"] = "55.00";
        dt.Rows.Add(myRow);
 
        myRow = dt.NewRow();
        myRow["ProjectID"] = "44";
        myRow["Description"] = "Cover Redesign";
        myRow["PurchaseDate"] = "03/09/2008";
        myRow["PurchaseType"] = "Service";
        myRow["OrderNumber"] = "000184";
        myRow["Amount"] = "1290.00";
        dt.Rows.Add(myRow);
 
        myRow = dt.NewRow();
        myRow["ProjectID"] = "55";
        myRow["Description"] = "Manuscript Rework";
        myRow["PurchaseDate"] = "03/08/2008";
        myRow["PurchaseType"] = "Service";
        myRow["OrderNumber"] = "000185";
        myRow["Amount"] = "99.00";
        dt.Rows.Add(myRow);
 
        myRow = dt.NewRow();
        myRow["ProjectID"] = "55";
        myRow["Description"] = "Manuscript Rework";
        myRow["PurchaseDate"] = "03/05/2008";
        myRow["PurchaseType"] = "Service";
        myRow["OrderNumber"] = "000186";
        myRow["Amount"] = "65.00";
        dt.Rows.Add(myRow);
 
        ds.Tables.Add(dt);
        return ds;
    }

Open in new window

0
Comment
Question by:sbornstein2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
codeclay earned 2000 total points
ID: 21778167
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question