Normally we delete a List item using following code,

using (SPSite site = new SPSite("http:web1/default.aspx"))
                using (SPWeb web = site.OpenWeb())
                    web.AllowUnsafeUpdates = true;

                    SPList list = web.Lists["MyList"];

                    SPListItemCollection listItems = list.Items;

                    foreach (SPListItem item in listItems)
                            if (item.DisplayName == "HyperLink")

                    web.AllowUnsafeUpdates = false;

I want to compare a HyperLink or Name/Title of HyperLink to the item and delete it, instead of title or DisplayName as its always coming as "(no title)" while debugging.

I Know I need to create an XML node in order to do this but any other way, tutorial or how to do it using XML node will be appreciated.


1 Answer 1


Because SharePoint let User to leave Title Field empty, so I created a Added List Item Event receiver that takes name of Item and assign its value to Title field. hence I didn't needed to delete a item using hyper link any more.


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.