In SAP Business One SDK, filling a gridview and button saves in database

This can be achieved in multiple ways. You can either use a SAP DI documents, an open SQL or use data transfer workbench for this purpose.

You can use a direct SQL write as this is one of straight way to do this. It is also possible to use SAP-DI Documents object to iterate over the Purchase Orders.

One more option is using Data Transfer Workbench (DTW), where you export it to a file and then using DTW. It also provides error handling incase any exception occurs.