• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

Message before deletion

Experts,

I have a gridview, and Edit/delete options for each row.  When users clicks on delete, i want to display a pop up warning window asking " are you sure you want to delete this row? "  with yes or cancel button in this popup window.  Please give me the code to do so in javascript or VB.net.

Thx
0
suran78
Asked:
suran78
1 Solution
 
suran78Author Commented:
here is the autogenerated delete option, how can i add a delete confirmation message to it?

<asp:DetailsView ID="dvCCenter" runat="server" AutoGenerateRows="False" DataKeyNames="intCID"
        DataSourceID="CCenters" OnDataBound="CCenter_DataBound" AutoGenerateInsertButton="True"
        AutoGenerateDeleteButton="True">
0
 
rajeeshmcaCommented:
Hi Suran78,

u cannot attach an javascript confirm message before delete for an autogenerated delete button...

u will have to create a templatefield with the delete button and attach the javascript as follows:

<asp:DetailsView ID="SampleDetailsView" runat="server" AutoGenerateDeleteButton="false">
                <Fields>
                    <asp:TemplateField HeaderText="Test">
                        <ItemTemplate>
                            <asp:Label ID="TestLabel" runat="server" Text='<%# Bind("Id") %>'>
                            </asp:Label>
                        </ItemTemplate>
                        <ItemTemplate>
                            <asp:Button ID="TestButton" runat="server" Text="Delete"
                             OnClientClick="return confirm('Are u Sure u want to Delete?')" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Fields>
            </asp:DetailsView>
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now