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.It emDataBound += new
System.Web.UI.W ebControls.Data GridItemEventHa ndler(this.dgGr id1_ItemDataBou n
d); //put this line of code in the InitializeCompo nent method or in the
PageLoad event
private void dgGrid1_ItemDat aBound(object sender, DataGridItemEve ntArgs e)
{
try
{
if(e.Item.ItemT ype==ListItemTy pe.Item
||e.Item.ItemTy pe==ListItemTyp e.AlternatingIt em)
{
LinkButton lbtn=(LinkButto n)e.Item.FindCo ntrol("btnDelet e");
if(lbtn!=null)
{
lbtn.Attributes .Add("onclick", "return confirm('Are you sure you want to
delete?');");
}
}
}
catch(Exception ex)
{
throw ex;
}
}
Prodip
"RSB" <rs*****@hotmai l.com> wrote in message
news:GA******** ********@news.c pqcorp.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.Attri butes.Add("onCl ick", "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