Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Database

Update multiple records on the List page

Scroll Prev Next More

 

To update multiple records on the List page at the same time, you can create a new Update selected button, then choose records on the List page and click the Update selected button.

 

1. Proceed to the Page Designer screen.

 

2. Create the Update selected custom button and add the following code to the Server tab:

 

for (int i=0; i < keys.Count(); i++)
{
  // set ReportsTo field to 'Bob Smith'
  string sql = "Update employees set ReportsTo='Bob Smith' where KeyField=" + keys[i]["KeyField"].ToString();
  tDAL.CustomQuery(sql);
}
result["txt"] = "Records were updated.";

 

and to the Client After tab:

 

var message = result["txt"];
ctrl.setMessage(message);

 

The Client Before tab should be blank (delete sample code there if you have any).

See also:

Database API

Tri-part events

Button object: getNextSelectedRecord()

About SQLQuery class

AJAX helper object: setMessage()