I find aut a this article about to easy and fast delete a records from list: http://spservices.codeplex.com/discussions/245147 How could I use it ? Can I use it on cs files, if yes so how can I use it ? Where should it be written ?


I don't know about SPServices, but here is the method I am using to delete a record from a list.

function DeleteRecordFromList(listName,recordId){
    url: '/_vti_bin/listdata.svc/'+listName+'('+recordId+')',
    type: "DELETE",
    contentType: "application/json; charset=utf-8",
    success: function () {
        alert("Record has been deleted");

    error: function (xhr, ajaxOptions, thrownError) {
        alert(xhr.status + " " + thrownError);

Be careful, the list name is case sensitive! If you want to do it from C#, you have instantiate an HttpRequest and call the same url as in the ajax call above. But if you are already in C#, why not just use the Object Model? Why to use jQuery? More about listdata.svc: http://msdn.microsoft.com/en-us/library/ff798339.aspx

I hope it helped!

  • +1 "But if you are already in C#, why not just use the Object Model?" – RJ Cuthbertson Nov 29 '12 at 14:26
  • But how Use It. I must send a IDis from C# by the Hiddenfield, or somthing better ? – Grzegorz Z Nov 29 '12 at 14:28
  • Can it be do from Event Receiver ? – Grzegorz Z Nov 29 '12 at 14:29
  • 1
    Well, you could use a global javascript variable like: var ID = '<%= IdPropertyFromCodeBehind%>'; See [this] (sharepoint.stackexchange.com/questions/52713/…) post too, maybe. – Norbert Nov 29 '12 at 14:31
  • 1
    Ok, so if I understood you correctly: you want to cascade delete items from the SecondList when you delete an item from the First list. In this case, please consider adding an extra column to the SecondList to hold the ID of the "parent" from the FirstList. Add an EventReceiver on ItemDeleting on the FirstList, and delete all items also from SecondList where secondListItem["ParentId"] == idBeingDeleted. – Norbert Nov 29 '12 at 15:48

I am not repeating the steps for jQuery as it's already described by @Norbert, but you can have a look at this post for C# way

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.