protected void MarginDetailsView_ItemCreated(object sender, EventArgs e) { // As each button in the command field is created, it detects if the button is the delete button. // If it is, an attribute is added to make a javascript prompt display to confirm the action when pressed. int commandRowIndex = MarginDetailsView.Rows.Count - 1; if (commandRowIndex != -1) { DetailsViewRow row = MarginDetailsView.Rows[commandRowIndex]; if (row.Controls[0].Controls.OfType <Button>().Where(b => b.CommandName == "Delete").Count() > 0) { Button btnDelete = row.Controls[0].Controls.OfType <Button>().Where(b => b.CommandName == "Delete").FirstOrDefault(); btnDelete.Attributes["onclick"] = "if(!confirm('Do you want to delete this Margin?')){ return false; };"; } } MarginGridView.DataBind(); }
protected void MarginDetailsView_ItemCommand(object sender, DetailsViewCommandEventArgs e) { MarginGridView.DataBind(); }