private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
LinkButton lnkbtnDelete = (LinkButton)e.Item.FindControl("LinkButton3");
lnkbtnDelete.Attributes.Add("onclick","return confirm('Are you sure to delete this line ?')");
}
}
就这样就行了。