wie hinzufügen, löschen, die Sicherheitsabfrage für "command" - Feld in der detail-Ansicht?

Ich möchte fordert den Benutzer zur Bestätigung, wenn er versucht, einen Datensatz löschen in der detail-Ansicht? Ich habe Befehl abgelegt, in dem showDeletebutton auf true gesetzt.

Fand ich, wie zu tun, die Bestätigung für eine gridview, aber wie kann ich ändern, um die übereinstimmung der detail-Ansicht?

Code:

protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
    //loop all data rows
    foreach (DataControlFieldCell cell in e.Row.Cells)
    {
       //check all cells in one row
       foreach (Control control in cell.Controls)
       {
            //Must use LinkButton here instead of ImageButton
            //if you are having Links (not images) as the command button.
            ImageButton button = control as ImageButton;
            if (button != null && button.CommandName == "Delete")
                //Add delete confirmation
                button.OnClientClick = "if (!confirm('Are you sure " + 
                       "you want to delete this record?')) return;";
        }
    }
}
}

Jemand?

InformationsquelleAutor Sas | 2012-02-16

Schreibe einen Kommentar