"AJMAL YAZDANI" wrote in message news:20****************@istsinc.com...
In my GridView, I am using "BoundFiled" for "Delete" functionality instead
of "ItemTemplate".
Now, I want a "Delete Confirmation" with Javascript.
What I have to do.
In the ItemDataBound event, add the javascript code to your boundfield:
private void myGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
string script = "javascript
:return confirm('Are you sure?')";
if (e.Item.ItemType!=ListItemType.Header &&
e.Item.ItemType!=ListItemType.Footer)
{
ImageButton imgButton = (ImageButton)e.Item.Cells[0].Controls[1];
if (imgButton.CommandName == "Delete")
{
imgButton.Attributes["onclick"] = script;
}
}
}
Obviously, in the preceding code, you will have to replace the
Cells[0].Controls[1] with the location of your actual control, and if it is
not an ImageButton you will also have to change the type also.