Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:42:44+00:00 2026-05-30T03:42:44+00:00

I want to prompt the user for confirmation when he tries to delete a

  • 0

I want to prompt the user for confirmation when he tries to delete a record in a detail view? I have command filed in which showDeletebutton set to true.

I found how to do the confirmation for gridview, but how can I modify to match detail view?

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;";
        }
    }
}
}

Anybody?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:42:46+00:00Added an answer on May 30, 2026 at 3:42 am

    I found the answer to my question.

    My answer:

     protected void DViewComputer_DataBound1(object sender, EventArgs e)
    {
        int noRow = DViewComputer.Rows.Count - 1;//get the no of record
    
        if (noRow >0)
        {
            Button button = (Button)(DViewComputer.Rows[noRow].Cells[0].Controls[2]);
    
            // Add delete confirmation
            ((System.Web.UI.WebControls.Button)(button)).OnClientClick = "if (!confirm('Are you sure " +
                                   "you want to delete this record?')) return;";
    
        }
    }
    

    Anyways thanks for your help guys.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before the user closes the form I want to prompt with a confirmation box.
I want to compile C code from the Command Prompt in Windows. I have
I want to prompt a user to cut from a 'last' command along with
I want to prompt a user via command line & ask what specific rows
I have a frame, and want to prompt when the user closes it to
I want to prompt the user for a directory name, and have them able
I want to prompt a user if he wants to do the operation (delete)
I have created a file, using fopen('contacts','w'). now i want to prompt user to
I want to prompt the user for a confirmation when they want to close
I want to prompt the user for some input detail, and then use it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.