Friday, 29 November 2013

programmatically reterive item from sharepointlist using caml query in sharepoint

Share it Please

            SPSite mySite = new SPSite(SPContext.Current.Site.ID);
            SPWeb myWeb = mySite.OpenWeb();
            SPList myList = myWeb.Lists["ListName"];
            SPQuery query = new SPQuery();
            string CurrentDate = DateTime.Now.ToString("yyyy-MM-dd");
            query.Query = "<Where><Eq><FieldRef Name=\"DOB\" /><Value IncludeTimeValue=\"FALSE\" Type=\"DateTime\">" + CurrentDate + "</Value></Eq></Where>";
            query.RowLimit = 10;
            SPListItemCollection items = myList.GetItems(query);
            DataTable dt = items.GetDataTable();

No comments:

Post a Comment

Followers

Follow The Author