Quantcast
Viewing all articles
Browse latest Browse all 26374

Sharepoint -CAML query not being applied when I run the code in c# ,help.

 

i am trying to run the below code to get the list of filtered items from the list.

string Qry= @"<Where><Eq><FieldRef Name='Curriculum_x0020_Code' /><Value Type='Text'>Code_002</Value></Eq></Where>";

using (SPSite site = SPContext.Current.Site)             {                 using (SPWeb web = site.OpenWeb())                 {                     SPList list = web.Lists[ListName] as SPList;                     if (null != list)                     {                         SPQuery qry = new SPQuery();                         qry.Query= Qry;                                     items = list.GetItems(qry);                                             }                 }             }

 

whenever I run this query, I am getting the all the records not the filtered one. I am getting the desired results if i run this CAML query  in CAML query helper utility.

I guess they query is not at all applied to the sharepoint object SPList . I am not sure where the problem is, I am always getting all the records irrespective of the criteria.

List columns:

Chapter Icon

Single line of text

Video To Embed

Single line of text

Curriculum Code

Single line of text

 

 

Curriculum_x0020_Code corresponds to the column "Curriculum Code" which is the display name.

 

Please help

 



regards,sridhar


Viewing all articles
Browse latest Browse all 26374

Trending Articles