none
add a row before a specified datavalue RRS feed

  • Question

  • i have a table and i am trying to group date according to a set ....

    and so i want to separate each group by a row

    as you can see below when insert a row group above a data set, it puts a row in between each data value

    so how can i code it so the it will put a row  only above only if first name = ozzy or barney

    so you ll end up having ozzy and franck group together,   barney by itself and homer on top

    IndividualId                  First Name          Last Name             DateCreated
    1                                  Homeer             Simpson                   5/14/2012  7:13:14 PM
    2                                  Barney              Rubble                     5/14/2012   7:13:41 PM
    3                                  Ozzy                    OsBourne              5/14/2012   7:13:46 PM
    4                                  Franck              THE MAN                    5/14/2012  7:15:39 PM

    • Moved by Val MazurModerator Tuesday, May 22, 2012 5:46 PM (From:ADO.NET Managed Providers)
    Thursday, May 17, 2012 12:14 AM

Answers

  • Hello, when you indicate "Table" are you saying this is a DataTable, a DataTable in a DataSet or a table in a database? If you are refering to a DataTable you can use InsertAt method to insert a new DataRow. If you are dealing with a table in a database the row is added to the table and not inserted like you are looking for under normal conditions unless you collect the data in a DataTable, clear out the table in the database then add the DataTable rows into the database. If IndividualId is an auto-incrementing column most databases would begin the new row at 5 if the last one (as you show) is 4. In regards to the condition to place a new row, it is not clear what indicates that ozzt abd franck are to be grouped together and on top of homer. With this said I would suggested indicating the exact rule to this grouping instead of the current explaination.

    Concerning "borderstyle = none", neither DataTable or DataSet have a border so you mus be asking about a Border Style for something like a DataGridView?


    KSG

    Friday, May 18, 2012 6:59 AM

All replies

  •         // Desing table look like this before adding a row above dataset and the previous is like i said above 

             IndividualId                  First Name          Last Name             DateCreated

           --->row will be inserted here

             [IndividualId]                  [FirstName]         [LastName]              [DateCreated]

    // after inserting a r0w ( borderstyle = none)above  this how it looks like

    IndividualId                  First Name          Last Name             DateCreated

    1                                  Homeer             Simpson                   5/14/2012  7:13:14 PM

    2                                  Barney              Rubble                     5/14/2012   7:13:41 PM

    3                                  Ozzy                    OsBourne              5/14/2012   7:13:46 PM

    4                                  Franck              THE MAN                    5/14/2012  7:15:39 PM

    Thursday, May 17, 2012 12:20 AM
  • // below is what i want to see in the design

    IndividualId                  First Name          Last Name             DateCreated
    1                                  Homeer             Simpson                   5/14/2012  7:13:14 PM

    2                                  Barney              Rubble                     5/14/2012   7:13:41 PM

    3                                  Ozzy                    OsBourne              5/14/2012   7:13:46 PM
    4                                  Franck              THE MAN                    5/14/2012  7:15:39 PM

    Thursday, May 17, 2012 12:21 AM
  • Hello, when you indicate "Table" are you saying this is a DataTable, a DataTable in a DataSet or a table in a database? If you are refering to a DataTable you can use InsertAt method to insert a new DataRow. If you are dealing with a table in a database the row is added to the table and not inserted like you are looking for under normal conditions unless you collect the data in a DataTable, clear out the table in the database then add the DataTable rows into the database. If IndividualId is an auto-incrementing column most databases would begin the new row at 5 if the last one (as you show) is 4. In regards to the condition to place a new row, it is not clear what indicates that ozzt abd franck are to be grouped together and on top of homer. With this said I would suggested indicating the exact rule to this grouping instead of the current explaination.

    Concerning "borderstyle = none", neither DataTable or DataSet have a border so you mus be asking about a Border Style for something like a DataGridView?


    KSG

    Friday, May 18, 2012 6:59 AM