how to set various level ROW INDEX on a data table?
<p>I have a C# data table with below sample data,</p>

<p><img src="http://i.stack.imgur.com/xpVfC.jpg" alt="enter image description here"></p>

<p>Now, I am trying to add 3 more columns as row number (starts with zero in descending order) on 3 different level "Category" ("Grand_Total", "Overall_Total" and "PROJ_TOTAL"), here is I'm trying to achieve,
<img src="http://i.stack.imgur.com/74qip.jpg" alt="enter image description here"> </p>

<p>I able to add ONLY one column "G_T_I" with total number of rows in datatable logic, but not able to figure out the logic to crack other 2 columns "O_T_I" and "P_T_I".
Please help/suggest?</p>

<pre><code>class Program
{
    static void Main(string[] args)
    {
        // Get the DataTable.
        DataTable table = GetTable();

        //get new data table 
        DataTable newTable = GetNewTable();

        for(int i = table.Rows.Count - 1; i &gt; -1; i--)
        {
            var gTotalIndex = (table.Rows.Count - i) - 1;
            newTable.Rows.Add(i, table.Rows[gTotalIndex]["Category"], table.Rows[gTotalIndex]["Name"], table.Rows[gTotalIndex]["PROJID"], table.Rows[gTotalIndex]["Type"], table.Rows[gTotalIndex]["Amt"]);
        }

    }

    static DataTable GetNewTable()
    {
        DataTable table = new DataTable();
        table.Columns.Add("G_T_I", typeof(int));
        table.Columns.Add("Category", typeof(string));
        table.Columns.Add("Name", typeof(string));
        table.Columns.Add("PROJID", typeof(string));
        table.Columns.Add("Type", typeof(string));
        table.Columns.Add("Amt", typeof(decimal));
        return table;
    }

    static DataTable GetTable()
    {
        DataTable table = new DataTable();
        table.Columns.Add("Category", typeof(string));
        table.Columns.Add("Name", typeof(string));
        table.Columns.Add("PROJID", typeof(string));
        table.Columns.Add("Type", typeof(string));
        table.Columns.Add("Amt", typeof(decimal));

        table.Rows.Add("NEW_PROJ", "ABC", "100", "Acost", 10);
        table.Rows.Add("SAME_PROJ", "", "", "Bcost", 20);
        table.Rows.Add("PROJ_TOTAL", "", "100 Total", "", 30);
        table.Rows.Add("NEW_PROJ", "", "200", "Acost", 40);
        table.Rows.Add("PROJ_TOTAL", "", "200 Total", "", 40);
        table.Rows.Add("OVERALL_TOTAL", "ABC Total", "", "", 70);
        table.Rows.Add("NEW_PROJ", "PQR", "300", "Acost", 10);
        table.Rows.Add("SAME_PROJ", "", "", "Bcost", 10);
        table.Rows.Add("PROJ_TOTAL", "", "300 Total", "", 20);
        table.Rows.Add("OVERALL_TOTAL", "PQR Total", "", "", 20);
        table.Rows.Add("GRAND_TOTAL", "", "", "", 90);

        return table;
    }
}
</code></pre>
