Click here to Skip to main content
15,886,780 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Agent:

Brittan Ropchock
Brittany York
Connie Ackerman
Dorothy Kester
Jessica Oakes
Jon Fedorek
Kale Granda (Support)
Kateri Hall
Kathy Roof
Katie Drake
Leona Siliga (Support)
Leslie Keyes
Matt Silvers
Rebecca Larsen
Sandra Lewis
Sara Barnhart

Totals:

Barbara Macormac
Cassandra York
Corinda Brady
DeNeal Fox
James Moyer
Marla Stearns
Megan Amacher

Totals:

Amber Staub
Lea McGuinn
Nathan Lytle

Totals:

Jacob Balmer
Kelly O'Malley
Kristin Rakoczy
Sara Guerra
Stephanie Beatty
Stephanie Turner

Totals:

Alex Medrano
Brad Starks
Brichelle Humphrey
Byron Phillips
Chad Mitchell
Daniel McAteer
Daniel Montez
Joseph Salazar
Lawrence Evans
Lee Davis
Lottie Conway
Matt Stewart
Miguel Campos
Mirrie Mitchell
Nathan Morris
Sandra Reyes
Steven Coleman
Venessa Trevino

Nora Caro


I have a datatable like this..I want to split it like
Brittan Ropchock
Brittany York
Connie Ackerman
Dorothy Kester
Jessica Oakes
Jon Fedorek
Kale Granda (Support)
Kateri Hall
Kathy Roof
Katie Drake
Leona Siliga (Support)
Leslie Keyes
Matt Silvers
Rebecca Larsen
Sandra Lewis
Sara Barnhart

Barbara Macormac
Cassandra York
Corinda Brady
DeNeal Fox
James Moyer
Marla Stearns
Megan Amacher

I dnont want Totals: and Agents: row value.

I need it urgently.Thanks if any help will be provided
Posted
Comments
Maciej Los 2-Jun-15 7:03am    
Not a question at all! It's impossible to help you if you do not provide details.

1 solution

Try this:

C#
DataSet ds = new DataSet();
DataTable dt= null;
//srcDt - it's datatable object which contains above data
foreach(DataRow dr in srcDt.Rows)
{
    if(dr[0]=="Totals:" || dr[0]=="Agent:")
    {
        dt = new DataTable();
        DataColumn dc = new DataColumn("FullName", Type.GetType("System.String"));
        dt.Columns.Add(dc);
        ds.Tables.Add(dt);
    }
    else
    {
        if(dr[0].ToString().Trim()!=string.Empty)
        {
            string tmp = dr[0].ToString();
            dt.Rows.Add(new Object[]{tmp});
        }
    }
}
//completed!


Note: this is very basic sample. I do not guarantee that meet your needs.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900