A
Amelyan
I found an example (below) in www.codeproject.com showing how to enable
DataGrid's delete buttons with confirmation. However, the example didn't
explain why the complicated if-condition is the way it is.
I tried just having the one line of code that adds confirmation script
without if-condition. However, this didn't work properly. DataGrid would
delete items even though I clicked Cancel in confirmation dialog.
Could anyone explain why the if-condition should be the way it is below in
order for the confirmation to work properly in DataGrid?
Thanks,
Amelyan
//In the DataGrid onItemDataBound method, add the following:
if ( e.Item.ItemType == ListItemType.AlternatingItem
|| e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.SelectedItem )
{
e.Item.Cells[0].Attributes.Add( "onClick", "return confirm('Are you
sure you wish to delete this record?');");
}
//* Note the magic number [0] should be the column that the button is
located.
DataGrid's delete buttons with confirmation. However, the example didn't
explain why the complicated if-condition is the way it is.
I tried just having the one line of code that adds confirmation script
without if-condition. However, this didn't work properly. DataGrid would
delete items even though I clicked Cancel in confirmation dialog.
Could anyone explain why the if-condition should be the way it is below in
order for the confirmation to work properly in DataGrid?
Thanks,
Amelyan
//In the DataGrid onItemDataBound method, add the following:
if ( e.Item.ItemType == ListItemType.AlternatingItem
|| e.Item.ItemType == ListItemType.Item
|| e.Item.ItemType == ListItemType.SelectedItem )
{
e.Item.Cells[0].Attributes.Add( "onClick", "return confirm('Are you
sure you wish to delete this record?');");
}
//* Note the magic number [0] should be the column that the button is
located.