Get SharePoint List Items to SPListItemCollection using CAML with Two Parameters

using (SPSite oSpSite = new SPSite(SPContext.Current.Web.Url))
using (SPWeb oSPWeb = oSpSite.OpenWeb())

int Parameter_Id = 12; //Sample Interger Variable

sting Parameter_Name =”Udara” //Sample string variable

SPList list = oSPWeb.Lists.TryGetList(“SharePoint List”);

SPQuery qryEmp = new SPQuery();

qryEmp.Query = “<Where><And><Eq><FieldRef Name=’Id’/><Value Type=’Integer’>” +Parameter_Id+ “</Value></Eq><Eq><FieldRef Name=’Name’/><Value Type=’Text’>” + Parameter_Name + “</Value></Eq></And></Where>”; // CAML Query with two parameters

SPListItemCollection oSpListCln = list.GetItems(qryEmp); // Querying List




Author: eshan1604

Hi Guys, I'm Udara Eshan Ariyarathne from Sri Lanka. Currently i'm working as a Software Engineer (Microsoft Technologies). I'm sharing some IT related articles such as Development ,Configuration and Designing things what i have learn from day to day works. Hope it useful all of us. "Enjoying IT" Thanks & Regards, Udara Eshan Ariyarthne

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s