how to map datatable's Index to datagridview's rowId?
<p>i am writing a viewer using datagridview to load a text file and display an m row x n column table (the table is editable by the user).</p>

<p>the main aim of this viewer is to change the backcolor of the max in each column to red, and the min of each column to green, and also cells that exceeds a certain threshold to  pink. (i use a button to trigger the checkMinMax() method, which iterates through each column of the dataTable to extract lists of rows for min/max/exceed )</p>

<p>i am able to do this when i first load the data into the datatable. however, when i sort the datagridview and call the checkMinMax() again, the color is still fixed at the old position.</p>

<pre><code>public void setCellBackColor (List&lt;int&gt; rows, int col, Color color)
{
    foreach (int row in rows)
    { 
        dataGridView_data.Rows[row].Cells[col].Style.BackColor = color;  
    }
}
</code></pre>

<p>i understand that i am using the index of the datatable rather than the rowId of the datagridview. so my question is if there is a way to map my datatable's index to the rowId?</p>

<p>or is there a better way to do what i want to do ? </p>
