Confirm a delete in a Datagrid

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?
 
G

Guest

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top