Asish is right but I found in certain instances the ItemCreated is not
reliable. I used ItemDataBound of the datagrid to accomplish this.
this.dgGrid1.ItemDataBound += new
System.Web.UI.WebControls.DataGridItemEventHandler (this.dgGrid1_ItemDataBoun
d); //put this line of code in the InitializeComponent method or in the
PageLoad event
private void dgGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
try
{
if(e.Item.ItemType==ListItemType.Item
||e.Item.ItemType==ListItemType.AlternatingItem)
{
LinkButton lbtn=(LinkButton)e.Item.FindControl("btnDelete");
if(lbtn!=null)
{
lbtn.Attributes.Add("onclick","return confirm('Are you sure you want to
delete?');");
}
}
}
catch(Exception ex)
{
throw ex;
}
}
Prodip
"RSB" <rs*****@hotmail.com> wrote in message
news:GA****************@news.cpqcorp.net...
Hi Everyone,
i am using a ASP: DataGrid control in the page and for each row i have a
Delete Button Column. Every thing works fine.
But now i want to add a Java script confirmation check for the user that
Delete has been selected and are they sure to continue.
I have already used this Attributes.Add (
cmdDelete.Attributes.Add("onClick", "return confirmDelete();")
)
command for a Single delete button on the page but don't understand how to
add some thing same for the dataGrid Button.
Please help.
Thanks
RSB