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

Search a Particular Record With In a SharePoint List Using Linq Based on Title

Note:-
       Here Title is the Primary Key.

 string strPassWord=string.Empty;
            var context = new
LinqSampleDataContext(SPContext.Current.Web.Url);
            EntityList<LoginItem> login_Insert =
context.GetList<LoginItem>("Login");
            var query = from cs in login_Insert
                        where cs.Title.ToString() == txtUserName.Text

                        select new
                        {
                           strPassWord=cs.Password
                        };
            if (query.Count() > 0)
            {
                foreach (var q in query)
                {
                    txtPassWord.Text = q.strPassWord;
                    break;
                }
            }
            else
            {
                this.Controls.Add(new LiteralControl("No Record
Found"));
            }

No comments:

Post a Comment