Prasad Bolla's SharePoint Blog

Click Here to go through the Interesting posts within my Blog.

Click Here to go through the new posts in my blog.

Thursday, December 01, 2011

Delete ListItem using SharePoint Linq

Note:- Here Title is Primary Key.
var context = new LinqSampleDataContext(SPContext.Current.Web.Url);
            foreach (LoginItem item in context.Login)
            {
                if (item.Title == txtUserName.Text)
                {
                    context.Login.DeleteOnSubmit(item);
                }
            }

            context.SubmitChanges();
            this.Controls.Add(new LiteralControl("Record Successfully
Deleted"));

No comments:

Post a Comment