I am confused with SPQuery
. How can I use it to get listitem values. Let's say I have a list "Cinema" with 20 columns but i only want 4.
- Film ID
- Film Name
- Film Type
- Film Review
How can i get all list items using SPQuery and access them using SPListItemCollection.
Example. not working
spsite site = new site("portal.filmworld.com/abc")
spweb web = site.openweb();
{
splist li = web.lists["Films"];
spquery q = new spquery();
q.query = string.Format("<FieldRef Name='FilmID' /><FieldRef Name='FilmName' /><FieldRef Name='FilmType' /><FieldRef Name='FilmReview' />");
splistitemcollection items = li.getitems(q);
foreach(SPListItem item in items)
{
string name = item.filmName; <---- it's not working gives exception of null
}
}