Confirm a delete in a Datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a delete column in a datagird.
I would like to execute
cmdDelete.Attributes.Add("onclick", "return confirm('Delete this record?');")
somewhere.
Where is the right place to put this code?
 
Try the ItemDataBound event for the grid...

private void dgGrid1_ItemDataBound(Object sender, DataGridItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem )
{
LinkButton lbtnDelete = e.Item.FindControl("lbtnDelete") as LinkButton;
lbtnDelete.Attributes.Add("onclick", "return confirm('Delete this record?')");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top