how to implement delete confirmation in datagrid

Discussion in 'ASP .Net' started by DrData, Mar 21, 2005.

  1. DrData

    DrData Guest

    I'm working on an ASP.Net application written in C#. On one page,
    there are several datagrid controls used to display, edit and delete
    detail records relating to the master record also displayed on that
    page. Each row in each datagrid includes a Delete button (added at
    runtime by the code-behind page as a ButtonColumn) and an Edit button
    (added at runtime by the code-behind page as an EditCommandColumn).
    What is the quickest, easiest and most reliable way to add delete
    confirmation functionality, so that when the user clicks the Delete
    button, they must take some further action before the record is
    actually deleted?

    Thanks in advance for any help anyone can offer.

    I'm operating under the following constraints:
    1. This large application was written by a consultant, who did not
    document his work, and who is no longer available for modifications
    or bug corrections.
    2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
    environment, a bit overwhelmed by it, and trying to get the job done
    using the most straightforward & well-documented controls and
    coding techniques.
    3. All of our programmers (including those with substantial C#/Dot Net
    experience) have had tremendous problems debugging the Java-script
    code (both embedded in the C# source and generated by some of the
    consultant's proprietary routines) this application relies on, and so
    we're endeavoring to minimize its use as we correct and expand the
    application.
    4. In the _ItemCreated method for each datagrid, there is already some
    Java-script specified for the "onclick" event, and so if implementing
    delete confirmation requires adding more Java-script in the same
    place, it will have to co-exist with the existing Java-script.


    Posted Via Usenet.com Premium Usenet Newsgroup Services
    ----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    ----------------------------------------------------------
    http://www.usenet.com
     
    DrData, Mar 21, 2005
    #1
    1. Advertising

  2. Here's a good (and free) control to start with:

    Confirmed Buttons Control

    "This is a collection of buttons which request confirmation from the user
    before posting back to the server. Included is a normal button, a link
    button, and an image button. Also included are two DataGrid columns which
    subclass EditCommandColumn and ButtonColumn which add confirmation to the
    buttons"


    http://www.metabuilders.com/Tools/ConfirmedButtons.aspx

    "DrData" <-spam.invalid> wrote in message
    news:423f5a87$1_5@127.0.0.1...
    > I'm working on an ASP.Net application written in C#. On one page,
    > there are several datagrid controls used to display, edit and delete
    > detail records relating to the master record also displayed on that
    > page. Each row in each datagrid includes a Delete button (added at
    > runtime by the code-behind page as a ButtonColumn) and an Edit button
    > (added at runtime by the code-behind page as an EditCommandColumn).
    > What is the quickest, easiest and most reliable way to add delete
    > confirmation functionality, so that when the user clicks the Delete
    > button, they must take some further action before the record is
    > actually deleted?
    >
    > Thanks in advance for any help anyone can offer.
    >
    > I'm operating under the following constraints:
    > 1. This large application was written by a consultant, who did not
    > document his work, and who is no longer available for modifications
    > or bug corrections.
    > 2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
    > environment, a bit overwhelmed by it, and trying to get the job done
    > using the most straightforward & well-documented controls and
    > coding techniques.
    > 3. All of our programmers (including those with substantial C#/Dot Net
    > experience) have had tremendous problems debugging the Java-script
    > code (both embedded in the C# source and generated by some of the
    > consultant's proprietary routines) this application relies on, and so
    > we're endeavoring to minimize its use as we correct and expand the
    > application.
    > 4. In the _ItemCreated method for each datagrid, there is already some
    > Java-script specified for the "onclick" event, and so if implementing
    > delete confirmation requires adding more Java-script in the same
    > place, it will have to co-exist with the existing Java-script.
    >
    >
    > Posted Via Usenet.com Premium Usenet Newsgroup Services
    > ----------------------------------------------------------
    > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    > ----------------------------------------------------------
    > http://www.usenet.com
     
    Ken Cox [Microsoft MVP], Mar 21, 2005
    #2
    1. Advertising

  3. Here is an entire article written on that specific topic:
    http://www.dotnetjunkies.com/HowTo/1E7FEE4A-795C-4D33-A135-843EB07C94A8.dcik

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "DrData" <-spam.invalid> wrote in message
    news:423f5a87$1_5@127.0.0.1...
    > I'm working on an ASP.Net application written in C#. On one page,
    > there are several datagrid controls used to display, edit and delete
    > detail records relating to the master record also displayed on that
    > page. Each row in each datagrid includes a Delete button (added at
    > runtime by the code-behind page as a ButtonColumn) and an Edit button
    > (added at runtime by the code-behind page as an EditCommandColumn).
    > What is the quickest, easiest and most reliable way to add delete
    > confirmation functionality, so that when the user clicks the Delete
    > button, they must take some further action before the record is
    > actually deleted?
    >
    > Thanks in advance for any help anyone can offer.
    >
    > I'm operating under the following constraints:
    > 1. This large application was written by a consultant, who did not
    > document his work, and who is no longer available for modifications
    > or bug corrections.
    > 2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
    > environment, a bit overwhelmed by it, and trying to get the job done
    > using the most straightforward & well-documented controls and
    > coding techniques.
    > 3. All of our programmers (including those with substantial C#/Dot Net
    > experience) have had tremendous problems debugging the Java-script
    > code (both embedded in the C# source and generated by some of the
    > consultant's proprietary routines) this application relies on, and so
    > we're endeavoring to minimize its use as we correct and expand the
    > application.
    > 4. In the _ItemCreated method for each datagrid, there is already some
    > Java-script specified for the "onclick" event, and so if implementing
    > delete confirmation requires adding more Java-script in the same
    > place, it will have to co-exist with the existing Java-script.
    >
    >
    > Posted Via Usenet.com Premium Usenet Newsgroup Services
    > ----------------------------------------------------------
    > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    > ----------------------------------------------------------
    > http://www.usenet.com
     
    Steve C. Orr [MVP, MCSD], Mar 22, 2005
    #3
  4. DrData

    Betsuni Guest

    This is how I implemented a "Confirmation" on delete inside my
    datagrid

    HTML:
    <asp:TemplateColumn headertext="Del" headerstyle-width="20">
    <ItemTemplate>
    <asp:ImageButton id="Delete" alternatetext="Delete"
    commandname="Delete" onload="SetDeleteButton" runat="server"/>
    </ItemTemplate>
    </asp:TemplateColumn>

    C#:
    protected void SetDeleteButton(Object sender, EventArgs e) {
    ImageButton ib = (ImageButton)sender;
    //Set the graphic
    SetButtonGraphics(ib, "icons/delete.gif", "", "");
    //Set the javascript confirmation
    ib.Attributes.Add("onclick", "return confirm('Confirm deletion of
    record.');");
    }





    -spam.invalid (DrData) wrote in message news:<423f5a87$1_5@127.0.0.1>...
    > I'm working on an ASP.Net application written in C#. On one page,
    > there are several datagrid controls used to display, edit and delete
    > detail records relating to the master record also displayed on that
    > page. Each row in each datagrid includes a Delete button (added at
    > runtime by the code-behind page as a ButtonColumn) and an Edit button
    > (added at runtime by the code-behind page as an EditCommandColumn).
    > What is the quickest, easiest and most reliable way to add delete
    > confirmation functionality, so that when the user clicks the Delete
    > button, they must take some further action before the record is
    > actually deleted?
    >
    > Thanks in advance for any help anyone can offer.
    >
    > I'm operating under the following constraints:
    > 1. This large application was written by a consultant, who did not
    > document his work, and who is no longer available for modifications
    > or bug corrections.
    > 2. I'm a VB veteran but a relative newcomer to C# and the Dot Net
    > environment, a bit overwhelmed by it, and trying to get the job done
    > using the most straightforward & well-documented controls and
    > coding techniques.
    > 3. All of our programmers (including those with substantial C#/Dot Net
    > experience) have had tremendous problems debugging the Java-script
    > code (both embedded in the C# source and generated by some of the
    > consultant's proprietary routines) this application relies on, and so
    > we're endeavoring to minimize its use as we correct and expand the
    > application.
    > 4. In the _ItemCreated method for each datagrid, there is already some
    > Java-script specified for the "onclick" event, and so if implementing
    > delete confirmation requires adding more Java-script in the same
    > place, it will have to co-exist with the existing Java-script.
    >
    >
    > Posted Via Usenet.com Premium Usenet Newsgroup Services
    > ----------------------------------------------------------
    > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
    > ----------------------------------------------------------
    > http://www.usenet.com
     
    Betsuni, Mar 22, 2005
    #4
  5. Well nice approach normally call it on ItemDataBound!



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Patrick Olurotimi Ige, Mar 22, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sramruttun

    Re: delete confirmation in datagrid

    sramruttun, Jul 4, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    614
    sramruttun
    Jul 4, 2003
  2. Nedu N
    Replies:
    2
    Views:
    390
    Robert McLaws
    Dec 4, 2003
  3. JenHu
    Replies:
    6
    Views:
    5,242
    =?Utf-8?B?UGF1bCBK?=
    Feb 3, 2005
  4. Elton W
    Replies:
    0
    Views:
    3,305
    Elton W
    May 15, 2005
  5. =?Utf-8?B?QWxleCBNYWdoZW4=?=

    Client Side Confirmation on DataGrid "Delete" LinkButton

    =?Utf-8?B?QWxleCBNYWdoZW4=?=, May 2, 2006, in forum: ASP .Net
    Replies:
    8
    Views:
    9,690
    AcesHidden
    Nov 23, 2010
Loading...

Share This Page