I have made new custom list (throught sharepoint), and I have only add couple custom fields, which type is TEXT. I have rename that TEXT example "Extra". I know how I can read list through code. However, how I can check what information I'm reading? Who added the information? Here is picture of my list:
Here is my code:
List<string> list = new List<string>();
Guid webID = SPContext.Current.Web.ID;
Guid siteID = SPContext.Current.Site.ID;
SPSecurity.RunWithElevatedPrivileges(delegate() // Code runs as the "SharePoint\system" user
{
using (SPSite site = new SPSite(siteID))
{
using (SPWeb web = site.AllWebs[webID])
{
SPList spList = web.Lists["CList"];
SPListItemCollection collListItems = spList.Items;
foreach (SPListItem item in collListItems)
{
list.Add(item["Text"].ToString());
}
}
}
});
Like you can see that my code allows me read field Text, but how I can check if it movie or music, etc? And how I can check who have add that information?
ADDED:
Burrhus, thank you for your example. =)
But any idea, why foreach crashes: "One or more field types are not installed properly. Go to the list settings page to delete these fields."
query.Query = string.Concat(
"<Where><Eq><And>",
"<FieldRef Name='Title'/>",
"<Value Type='TEXT'>Movie</Value>",
"<FieldRef Name='Extra'/>",
"<Value Type='TEXT'>Horror</Value>",
"</And></Eq></Where>");
SPListItemCollection collListItems = spList.GetItems(query);
I'm trying to get all movies from my list, which extra field is "Horror".
and about querys, is this correct? (if someone, who has more knowledge, can ensure this?)