Grid.setValue does not work

I set up a test project with just one form and one grid (Grid1).

I then copied the following five lines of code from “Help/Language Reference”:

For row=0 to 3
  For col=0 to 3
    Grid1.setValue(row,col,row*col)
  Next
Next

and I pasted them into my test project as the only lines.

But when I deployed my test project to my server and then ran the project as a web app in Google Chrome I got the following error message:

Uncaught TypeError: 
Grid1.setValue is not a function.
line 3 column 15

*** Does anyone know why?

Thanks.

Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)

Where are you putting the code to set the values?

Grid takes a few moments to instantiate, so you can’t do this on startup. You’ll need to wait till Sub Main() executes.

Thanks.
This solved the problem.