On my site I had a problem on function GetWebImageByPage in the function Convert.ToInt32(.....["TotalPages"]) because the value was "1.2".
I've changed in "Gallery_GetWebImageByPage" this row:
sqlCommand.Append("SET @TotalPages = CEIL(@TotalRows / @PageSize) ;");