This is a migrated thread and some comments may be shown as answers.

How to add Delete functionality in RadDataForm?

2 Answers 98 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Pranav
Top achievements
Rank 1
Pranav asked on 12 Mar 2015, 03:07 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 17 Mar 2015, 11:21 AM
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.

 
0
Pranav
Top achievements
Rank 1
answered on 17 Mar 2015, 01:57 PM
Thank You Stefan!
Tags
DataForm
Asked by
Pranav
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Pranav
Top achievements
Rank 1
Share this question
or