ADO Database ASP.Net

<%@ Page Language="C#" %>

    void deptSource_Deleted(object sender,SqlDataSourceStatusEventArgs e)
    {
      if (e.Exception == null)
      {
        if (e.AffectedRows == 1)
        {
          lblResult.Text = "Record deleted successfully.";
        }
        else
        {
          lblResult.Text = "An error occurred during the delete operation.";
        }
      }
      else
      {
        lblResult.Text = "An error occurred while attempting to delete the row." + e.Exception.Message;
        e.ExceptionHandled = true;
      }
    }



    Deletion using SqlDataSource Control


    
    
        
                    ProviderName="System.Data.SqlClient" 
            ConnectionString="<%$ ConnectionStrings:AdventureWorks %>"
            SelectCommand="Select DepartmentID, Name, GroupName, ModifiedDate from HumanResources.Department"
            DeleteCommand="Delete from HumanResources.Department Where DepartmentID=@original_DepartmentID"            
            OldValuesParameterFormatString="original_{0}" OnDeleted="deptSource_Deleted">
                            
                
            

        
                    AutoGenerateColumns="False" 
            runat="server" 
            DataSourceID="deptSource"
            HeaderStyle-HorizontalAlign="Center" 
            HeaderStyle-Font-Bold="True"
            HeaderStyle-BackColor="blue" 
            HeaderStyle-ForeColor="White"
            DataKeyNames="DepartmentID">
            
                
                    
                                                    OnClientClick="return confirm('Are you sure you want to delete this record?');"
                            CommandName="Delete" />