How to add a “Delete” button to each row in grid

ASP.NET, PHP, PHP Code Generator, Tutorials

By default PHPRunner/ASPRunner.NET provide “Delete selected” functionality. In some cases you need to be able to delete records individually. In this tutorial we will show how to add a delete button to each record. We will also show how to make it look as a regular edit/copy/view buttons.

1. Proceed to the List page in Page Designer and insert a button. Move it to one of grid columns. Set button style to “link-button” and choose icon “glyphicon-remove” as appears on a screenshot below.

2. Now lets edit button’s code. We want to ask for a deletion confirmation, delete record and reload the page.

ClientBefore event:

if (confirm("Do you want to delete this record?"))
return true;
return false;

In Server event you will need to specify correct table and key column name. In our case table name is categories and key column name is CategoryID.

Server event PHP code:

$record = $button->getCurrentRecord();
$data = array();
$data["CategoryID"] = $record["CategoryID"];
DB::Delete("categories", $data );

Server event C# code:

XVar record = button.getCurrentRecord();
dynamic data = XVar.Array();
data["CategoryID"] = record["CategoryID"];
DB.Delete("categories", data );

Client After event:


This is it. Enjoy!

6 thoughts on “How to add a “Delete” button to each row in grid

  1. Can you double-check the C# code? It does not compile for me as written. I tried removing the third line which appears to be a mistake, and changed pageObject.getCurrentRecord(); in the first line to button.getCurrentRecord();. After these changes, the code compiles and no errors are generated upon running it, but the record does not get deleted. I did update the table and PK names.

  2. If it did not delete then please try changing

    DB.Delete(“categories”, data );


    DB.Delete(“dbo.categories”, data );

    If you are using MS SQL

  3. Is there a way to hide this delete button when doing an inline edit (the same way the edit button disappears)?


  4. @Tim,

    this won’t be that easy as you would need to intercept inline edit click. We do not have an API for this.

  5. Can we delete only certain columns/fields from a row using the same method?

Leave a Reply

Your email address will not be published.