Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
While Deleting a row from the Grid View, it should ask a confiramtion message. If we click on Ok record should be deleted.

ASP.NET
<asp:GridView ID="gvcoursetype" runat="server" AllowPaging="True" 
            AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
             ForeColor="#333333" GridLines="None" 
                     
                     onpageindexchanging="gvcoursetype_PageIndexChanging" Width="613px" 
                     onrowediting="gvcoursetype_RowEditing" 
                     onrowupdating="gvcoursetype_RowUpdating" 
                     onrowdeleting="gvcoursetype_RowDeleting" 
                     onrowcancelingedit="gvcoursetype_RowCancelingEdit" >
            <AlternatingRowStyle BackColor="White" />
           <Columns>
                <asp:BoundField DataField="Type_ID" HeaderText="Type ID" />
                <asp:BoundField DataField="Type_Name" HeaderText="Type Name"/>
                <asp:BoundField DataField="Description" HeaderText="Description"/>
                <asp:BoundField DataField="Branch_Code" HeaderText="Branch Code"/>
                <asp:CommandField ShowEditButton="true" />
                <asp:CommandField ShowDeleteButton="true"/>
                </Columns>
            
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True"         ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
            </asp:GridView>
Posted

Check the below link

Confirmation message

Hope it helps :)
 
Share this answer
 
XML
use this code in rowdeletedevent

<pre> Protected Sub gvcompany_RowDeleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeletedEventArgs) Handles gvcompany.RowDeleted
        Try
            lblcompanymessage.Visible = True
            If (e.AffectedRows &gt; 0) Then
                lblcompanymessage.Text = "Company row with companyID = """ &amp; e.Keys(0).ToString() &amp; """ is successfully deleted "
                lblcompanymessage.ForeColor = System.Drawing.Color.Navy
            Else
                lblcompanymessage.Text = "Company row with companyID = """ &amp; e.Keys(0).ToString() &amp; """ is not deleted due to data conflict"
                lblcompanymessage.ForeColor = System.Drawing.Color.Red
            End If

        Catch ex As Exception
            lblcompanymessage.Text = ex.Message.ToString()
        End Try
    End Sub</pre>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900