Get the list items in SharePoint 2010 List
The caml query to get the list items from the SharePoint 2010 list.
This is the Sample List - List name is "Details"
ID Title Address
1 B Bangalore
2 C Chennai
Scenario 1
SPList olist = web.Lists[“
Details ”];
SPQuery spQuery = new SPQuery();
spQuery.Query = “<Where><Eq><FieldRef Name="Title" />
<Value Type="Text">B</Value>
</Eq></Where>”
SPListItemCollection oitems = olist.GetItems(spQuery);
The Result is
ID Title Address
1 B Bangalore
Scenario 2
SPList olist = web.Lists["
Details ”];
SPQuery spQuery = new SPQuery();
spQuery.Query = “<Where><Eq><FieldRef Name="Title" />
<Value Type="Text">
C</Value>
</Eq></Where>”
SPListItemCollection oitems = olist.GetItems(spQuery);
The Result is
ID Title Address
2 C Chennai
No comments:
Post a Comment