You can only "Trim" on a string variable, the error you are getting suggested that "Value" is an object. How you deal with this depends on what is in the cell. The solution might be
SourcePageFile = SourceFolder + "\\pg-" + Convert.ToDecimal(DataGridView1.Rows[irow].Cells[0].Value.ToString().Trim(' ')) - 1 + ".jpg"
or
SourcePageFile = SourceFolder + "\\pg-" + Convert.ToDecimal(((string)DataGridView1.Rows[irow].Cells[0].Value).Trim(' ')) - 1 + ".jpg"
Also converting to decimal isn't the same as converting to int which is what the original did. Your code is also very fragile and prone to throwing an exception if values are not what you expect. You should use int.TryParse rather than Convert.ToDecimal. Google for usage.