Skip to main content
added 1172 characters in body
Source Link
Burrhus
  • 609
  • 3
  • 9

Its the same way. It seems as you are using the default Title field to determine if its music or movie.. and that is a text field. The created by field is Author - you can see the default names here http://blogs.msdn.com/b/michael_yeager/archive/2008/11/03/reference-list-for-internal-field-names.aspx

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"];
    SPQuery query = new SPQuery();
        query.Query = string.Concat(
                              "<Where><Eq>",
                                 "<FieldRef Name='Title'/>",
                                 "<Value Type='TEXT'>Movie</Value>",
                              "</Eq></Where>");                   
        SPListItemCollection collListItems = spList.GetItems(query); // You need to use getitems to get specific items look here http://msdn.microsoft.com/en-us/library/ms457534.aspx

        foreach (SPListItem item in collListItems)
        {
            list.Add(item["Author"].ToString()); // it's an internal field so you can use it
        }
    }
}
});

Its the same way. It seems as you are using the default Title field to determine if its music or movie.. and that is a text field. The created by field is Author - you can see the default names here http://blogs.msdn.com/b/michael_yeager/archive/2008/11/03/reference-list-for-internal-field-names.aspx

Its the same way. It seems as you are using the default Title field to determine if its music or movie.. and that is a text field. The created by field is Author - you can see the default names here http://blogs.msdn.com/b/michael_yeager/archive/2008/11/03/reference-list-for-internal-field-names.aspx

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"];
    SPQuery query = new SPQuery();
        query.Query = string.Concat(
                              "<Where><Eq>",
                                 "<FieldRef Name='Title'/>",
                                 "<Value Type='TEXT'>Movie</Value>",
                              "</Eq></Where>");                   
        SPListItemCollection collListItems = spList.GetItems(query); // You need to use getitems to get specific items look here http://msdn.microsoft.com/en-us/library/ms457534.aspx

        foreach (SPListItem item in collListItems)
        {
            list.Add(item["Author"].ToString()); // it's an internal field so you can use it
        }
    }
}
});
Source Link
Burrhus
  • 609
  • 3
  • 9

Its the same way. It seems as you are using the default Title field to determine if its music or movie.. and that is a text field. The created by field is Author - you can see the default names here http://blogs.msdn.com/b/michael_yeager/archive/2008/11/03/reference-list-for-internal-field-names.aspx