SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I find aut a this article about to easy and fast delete a records from list: 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 ?

share|improve this question
up vote 5 down vote accepted

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:

I hope it helped!

share|improve this answer
+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
Well, you could use a global javascript variable like: var ID = '<%= IdPropertyFromCodeBehind%>'; See [this] (…) post too, maybe. – Norbert Nov 29 '12 at 14:31
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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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