Line 4: Ever tried to use **end = Convert.ToInt32(dt.Rows[count-1][2].ToString());**?

Oops, I guess the syntax got to be more something like dt.Rows[count-1,2]. instead of dt.Rows[count-1][2].

Sorry, my fault, the syntax you used is correct.

Must have been a bit too late in the evening for me :$

You can used following code

//minimum

```
int min = dt.Rows[0][2]; // assuming you want the third column (index 2)
for(int i = 1; i < dt.Rows.Count; i++)
{
if(min > (int)dt.Rows[i][2]) min = (int)dt.Rows[i][2];
}
// maximum
int max = dt.Rows[0][2]; // assuming you want the third column (index 2)
for(int i = 1; i < dt.Rows.Count; i++)
{
if(max < (int)dt.Rows[i][2]) max = (int)dt.Rows[i][2];
}
```

Your Question is not so clear, Consider Following DataTable:

DataTable dt = new DataTable();

dt.Columns.Add("ID");

dt.Columns.Add("Name");

dt.Rows.Add(2, "Hari");

dt.Rows.Add(1, "Sharad");

dt.Rows.Add(3, "Gopal");

dt.Rows.Add(6, "Suman");

dt.Rows.Add(5, "Rabi");

-If You want to get value of just first and last row, it is more simple. Code is like:

int firstRowIdValue = Convert.ToInt32(dt.Rows[0]["ID"]);

int lastRowIdValue = Convert.ToInt32(dt.Rows[dt.Rows.Count - 1]["ID"]);

- But If You Want MIN And Max Value. Code will be as:

int minVal =Convert.ToInt32(dt.Compute("min(ID)", string.Empty));

int MaxVal = Convert.ToInt32(dt.Compute("max(ID)", string.Empty));

MessageBox.Show("Min Value=" + minVal.ToString() + " AND Max Value" + MaxVal.ToString());