Tuesday, May 22, 2007

JavaScript-Confirm using at AutoGenerateDeleteButton in case of grid view

Hook RowDataBound event of gridview and then use following code

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
LinkButton DeleteButton = (LinkButton)e.Row.Cells[0].Controls[0];
if (null != DeleteButton)
{
DeleteButton.OnClientClick = "return(confirm('Are you sure you want to delete this record?'))";
}

}

0 comments: