JavaScript Prompts for Buttons in ASP: DataGrid for delete column

xiaoxiao2021-03-06  61

AIM: TO JavaScript Prompts for Buttons in Asp :: DataGrid for delete column

Look at The Following Code Below. It has delete column, Which We Use to delete Items in The Grid. But Revete Is So Careful Action, We Require The JavaScript alert to confirm the delete operation.

To add javascript prompt command on click of delete button we can not directly modify the DataGrid tag. And DataGrid does not provide any facility to add alert code. However there is way to add an attribute to the controls. This way is very costly for server As Far as Performance is concerned. The old method is as shown below.

Old Slow Method (Not Recommended):

private void InitializeComponent () {TestGrid.ItemCreated = new DataGridItemEventHandler (TestGrid_ItemCreated);} void TestGrid_ItemCreated (object sender, DataGridItemEventArgs e) {Button btn = (Button) e.Item.Cells [4] .Controls [0]; btn. Attributes.Add ("Onclick", "'Are you have you want to delete this');