Adding a confirmation pop-up window for datagrid delete

Discussion in 'ASP .Net' started by Elton W, May 15, 2005.

  1. Elton W

    Elton W Guest

    Hi Peter,

    You use

    DeleteButton.Attributes.Add("onclick", "return confirm
    ('Are you sure you want to delete?');");

    in datagrid_ItemDataBound event to add confirmation for
    delete button.

    HTH

    Elton Wang



    >-----Original Message-----
    >(Type your message here)
    >
    >--------------------------------
    >From: Peter Rio
    >
    >Iam trying add pop up window for delete but i am having

    problem with it..i am using data grid with push button for
    the delete function plus am using java script on the
    client side(HTMT) but dont really know how to make the pop
    up work when the delete button is cliked..here is a html
    code..Anyhelp would be really appreciated.thanks
    >
    ><HTML>
    > <HEAD>
    > <title>ViewBooking</title>
    > <meta content="Microsoft Visual

    Studio .NET 7.1" name="GENERATOR">
    > <meta content="Visual Basic .NET 7.1"

    name="CODE_LANGUAGE">
    > <meta content="JavaScript"

    name="vs_defaultClientScript">
    > <meta

    content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    > <script language="javascript">
    > function confirm_delete()
    > {
    > if (confirm("Are you sure you want to

    delete this item?")==true)
    > return true;
    > else
    > return false;
    > }
    >
    > </script>
    > </HEAD>
    > <body bgColor="#ffffff"

    MS_POSITIONING="GridLayout">
    > <form id="Form1" method="post"

    runat="server">
    >
    > <asp:datagrid id="ViewBookingGrid"

    style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP:
    104px"
    > BorderStyle="Solid"

    BorderColor="Gray" Runat="Server"
    AutoGenerateColumns="False" CellPadding="1"
    >

    OnDeleteCommand="dg_Delete" Height="216px" Font-
    Size="X-Small" OnEditCommand="dg_Edit"
    OnUpdateCommand="dg_Update"
    >

    onCancelCommand="dg_Cancel" Font-Names="Arial"
    Width="712px" DataKeyField="Booking_ID">
    > <AlternatingItemStyle Font-

    Names="Arial" BackColor="#CCCCCC"></AlternatingItemStyle>
    > <ItemStyle

    ForeColor="Black"></ItemStyle>
    > <HeaderStyle Font-

    Size="10pt" Font-Names="Arial" Font-Bold="True"
    ForeColor="White" BackColor="#A2C1FF"></HeaderStyle>
    > <Columns>
    >

    <asp:EditCommandColumn ButtonType="PushButton"
    UpdateText="Update" CancelText="Cancel"
    EditText="Edit"></asp:EditCommandColumn>
    > <asp:BoundColumn

    DataField="Cust_Email" ReadOnly="True"
    HeaderText="Customer Email"></asp:BoundColumn>
    > <asp:BoundColumn

    DataField="Booking_Date" ReadOnly="True"
    HeaderText="Booking Date"></asp:BoundColumn>
    > <asp:BoundColumn

    DataField="Booking_Time" ReadOnly="True"
    HeaderText="Booking Time"></asp:BoundColumn>
    > <asp:BoundColumn

    DataField="Service_Type" ReadOnly="True"
    HeaderText="Service Type"></asp:BoundColumn>
    > <asp:BoundColumn

    DataField="Reported_fault" ReadOnly="True"
    HeaderText="Reported Fault"></asp:BoundColumn>
    > <asp:BoundColumn

    DataField="Model_Name" ReadOnly="True" HeaderText="Model
    Name"></asp:BoundColumn>
    > <asp:BoundColumn

    DataField="Model_No" ReadOnly="True" HeaderText="Model
    No"></asp:BoundColumn>
    > <asp:BoundColumn

    DataField="Sales_ID" ReadOnly="True" HeaderText="Receipt
    No"></asp:BoundColumn>
    >

    <asp:TemplateColumn>
    >

    <HeaderTemplate>
    >

    Status
    >

    </HeaderTemplate>
    >

    <ItemTemplate>
    > <%

    #Container.DataItem("Status")%>
    >

    </ItemTemplate>
    >

    <EditItemTemplate>
    >

    <asp:TextBox Id ="TxtStatus" Runat ="server" TexT
    ='<%#Container.DataItem("Status")%>'/>
    >

    <asp:RequiredFieldValidator ID="rfvStatus"
    Display="Dynamic" ErrorMessage="Status is required!"
    Controltovalidate="TxtStatus"
    >

    Runat="server" />
    >

    </EditItemTemplate>
    >

    </asp:TemplateColumn>
    > <asp:ButtonColumn

    Text="Delete" ButtonType="PushButton"
    CommandName="Delete"></asp:ButtonColumn>
    > </Columns>
    >
    >-----------------------
    >Posted by a user from .NET 247 (http://www.dotnet247.com/)
    >
    ><Id>oih8bs4PM0SjpdW9zA9rww==</Id>
    >.
    >
     
    Elton W, May 15, 2005
    #1
    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. Samy
    Replies:
    5
    Views:
    705
  4. Replies:
    0
    Views:
    379
  5. Mike Brearley

    adding delete confirmation

    Mike Brearley, Jul 6, 2004, in forum: ASP General
    Replies:
    4
    Views:
    184
    Mike Brearley
    Jul 6, 2004
Loading...

Share This Page