开发者

Sharepoint 2010 get items from multilookup

I have field in my list with type:

        Type="LookupMulti"

I need in c# code get values fro开发者_运维技巧m this field but i cannot understand how to do that. My tries:

  public static void GetFields(this SPListItem item)
    {
        var messages = item.GetLookup(new Guid("{0B72A4E1-FFFF-4D45-B07A-197D46D2989C}"));
    //messages  - no Value property..
        var test=item.Fields[new Guid("{0B72A4E1-FFFF-4D45-B07A-197D46D2989C}")];
        // var collection=new SPFieldLookupValueCollection(test.ToString()); - empty

    }

How can i get items from this item.Fields[...] lookup selected items?


Try removing .Fields from the setter to test:

public static void GetFields(this SPListItem item)
{
    var test=item[new Guid("{0B72A4E1-FFFF-4D45-B07A-197D46D2989C}")];
    var collection=new SPFieldLookupValueCollection(test.ToString());
}

You don't want to pass the SPField to SPFieldLookupValueCollection, you want to pass the value of the SPListItem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜