开发者

how sharepoint lookup column store its values?

I was trying to create a custom field type similar to lookup column just mine is filtered lookup column.Its working fine but I wanted to implement the same functionality like lookup column does,by that I mean:

For e.g lookup column is having title of some list so it stores its value as

SPListiem.ID#;title....but it shows only title when we r selecting or editing value in it.

I am 开发者_运维技巧using listboxes and doing

listbox.Items.Add(title);

but how to get Id also and specially hidden from users like lookup column does....means I can do like this... listbox.Items.Add(title+"#;" + SPListitem.ID)...

but I dont want this....

Any idea how to achieve this...


Your solution

Indeed, it stores value as LookupId;#LookupValue

  1. Use SPFieldLookupValue (or SPFIeldLookupValueCollection for multiple lookups) constructor and then you get SPFieldLookupValue.LookupId and SPFieldLookupValue.LookupValue properties.

  2. Then, to add items to ListBox with ID, use

    listbox.Items.Add(new ListItem(lookupValue.LookupValue, lookupValue.LookupId));
    

    then user will see LookupValue, but you will have a way to get coresponding ID.

Already existing solution

By the way, there is already available SharePoint filtered lookup field which you may use if you wish.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜