How to custom delete command in list.aspx or detail.aspx

Last post 07-02-2009 6:03 AM by sjnaughton. 8 replies.

Sort Posts:

  • How to custom delete command in list.aspx or detail.aspx

    06-30-2009, 11:51 PM
    • Member
      81 point Member
    • zzdfc
    • Member since 07-06-2004, 6:07 AM
    • Posts 72

    Hi:

         How to custom delete command in list.aspx or detail.aspx?

    I hope delete other data and write log after deleting a recorder in list.aspx or detail.aspx

  • Re: How to custom delete command in list.aspx or detail.aspx

    07-01-2009, 12:39 AM
    • Star
      10,348 point Star
    • chintanpshah
    • Member since 11-19-2008, 5:39 AM
    • Ahmedabad
    • Posts 1,857

    Can you please explain your requirement in detail? 

    Hope this helps...

    Don't forget to mark as answer, if it helps
  • Re: How to custom delete command in list.aspx or detail.aspx

    07-01-2009, 2:18 AM
    • Member
      81 point Member
    • zzdfc
    • Member since 07-06-2004, 6:07 AM
    • Posts 72

    example:

       I will write a "delete log" to table logs when I click delete linkbutton of gridview in List.aspx,how to do this? 

  • Re: How to custom delete command in list.aspx or detail.aspx

    07-01-2009, 4:58 AM
    • Contributor
      2,189 point Contributor
    • davidfowl
    • Member since 08-17-2008, 9:50 PM
    • Redmond
    • Posts 450
    • AspNetTeam
      Moderator

    You can handle the events on the Deleting/Deleted events on the datasource.

    David Fowler
    SDE, ASP.NET Team, Microsoft
  • Re: How to custom delete command in list.aspx or detail.aspx

    07-01-2009, 4:59 AM
    • Star
      12,160 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,548
    • TrustedFriends-MVPs

     What are you using Entity Framework or Linq to SQL?

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
    Filed under:
  • Re: How to custom delete command in list.aspx or detail.aspx

    07-01-2009, 10:15 AM
    • Member
      81 point Member
    • zzdfc
    • Member since 07-06-2004, 6:07 AM
    • Posts 72

    I am using Entity Framework.

    I don't find OnCommand event of linkbutton delete in GridView of list.aspx .

  • Re: How to custom delete command in list.aspx or detail.aspx

    07-01-2009, 11:22 AM
    • Star
      12,160 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,548
    • TrustedFriends-MVPs

     Hi Zzdfc, your best bet is to handle the EntityDataSource's OnDeleting event e.g:

    protected void GridDataSource_Deleting(object sender, EntityDataSourceChangingEventArgs e)
    {
        var entity = e.Entity;
    }
    


    You can get the actual entity from e.Entity and then do what ever you want before letting the EDS finish the delete.

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
    Filed under:
  • Re: How to custom delete command in list.aspx or detail.aspx

    07-01-2009, 11:20 PM
    • Member
      81 point Member
    • zzdfc
    • Member since 07-06-2004, 6:07 AM
    • Posts 72

    Hi sjnaughton:

        What code do it execute  after I click linkbutton "Delete" of grieview in list.aspx,please?

    I want to know deeper, thanks!

  • Re: How to custom delete command in list.aspx or detail.aspx

    07-02-2009, 6:03 AM
    Answer
    • Star
      12,160 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,548
    • TrustedFriends-MVPs

     Hi Zzdfc, you could do domething like this:

    protected void GridDataSource_Deleting(object sender, EntityDataSourceChangingEventArgs e)
    {
        var entity = e.Entity as Employee;
        var DC = new Models.NorthwindDataContext();
    
        var log = new Log()
        {
             EntityID = entity.EmployeeID,
             TimeDeleted = DateTime.Now,
             DeletedBy = User.Id
        };
    }

    However if you wanted to just mark the employee as deleted instead of deleting them then you could USE SPROCS to replace default L2S or EF actions see:

    EF: http://blogs.msdn.com/meek/archive/2008/03/26/ado-entity-framework-stored-procedure-customization.aspx

    L2S: http://blog.benhall.me.uk/2008/01/custom-insert-logic-with-linq-to-sql.html


     

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
    Filed under:
Page 1 of 1 (9 items)