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
Use SPFieldLookupValue (or SPFIeldLookupValueCollection for multiple lookups) constructor and then you get SPFieldLookupValue.LookupId and SPFieldLookupValue.LookupValue properties.
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.
精彩评论