This is what I did:
- Created a new document 100 pixels square.
- Using the line tool I drew the lines. I also used Edit>Stroke to add a line around a selction (the image border) and Edit>Fill for the background color.
- Flatten the image, then selected it all (Ctrl+A) and then Edit>Define Pattern. This adds it to the pattern browser.
- Created a new document 1000 pixels square.
- Selected all, then Edit>Fill. In the dialog chose pattern and then selected the custom pattern added at (3).

You need to make sure the pattern you define is the right size to give you the number of whole grid squares you want. You can’t have fractions of a pixel so that’s why my example is 1000 pixels square rather than 1024. Ten squares across a 1024 pixel image would mean a single square was 102.4 pixels wide which you can’t have.