Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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")
                            {
                                item.Delete();
                                list.Update();
                            }
                        }

                    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.

Cheers

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

cheers

share|improve this answer
add comment

Your Answer

 
discard

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.