How to add Delete functionality in RadDataForm?

3 posts, 1 answers
  1. Pranav
    Pranav avatar
    3 posts
    Member since:
    Mar 2015

    Posted 12 Mar 2015 Link to this post

    I am trying to delete a field in database(using linq) corresponding to item on which delete button is clicked. the code is same as:http://demos.telerik.com/silverlight/#DataForm/FirstLook.how can i implement that?
  2. Answer
    Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 17 Mar 2015 Link to this post

    Hello Pranav,

    To achieve this you can subscribe to the DeletedItem event of RadDataForm:
    this.myDataForm.DeletedItem += myDataForm_DeletedItem;


    Then you should be able to build a LINQ query within the event handler method:
    void myDataForm_DeletedItem(object sender,
        Telerik.Windows.Controls.Data.DataForm.ItemDeletedEventArgs e)
    {
        var club = e.DeletedItem as Club;
        if (club != null)
        {
            var remove = (from removeClub in db.clubs
                          where removeClub.name == club.Name
                          select removeClub).FirstOrDefault();
     
            if (remove != null)
            {
                db.clubs.DeleteOnSubmit(remove);
            }
        }
    }

    I hope that this helps.

    Best Regards,
    Stefan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Pranav
    Pranav avatar
    3 posts
    Member since:
    Mar 2015

    Posted 17 Mar 2015 in reply to Stefan X1 Link to this post

    Thank You Stefan!
Back to Top