I think about how to add a from lookup value to the text ? How can I write it to another colum ? In the same list.

  • Yes :), only Value from lookup field. – Grzegorz Z Nov 28 '12 at 10:03
  • And how get a LookupField in Event Receiver ? – Grzegorz Z Nov 28 '12 at 11:25
  • but why LookupListName_x003a_ID ? Why why wrait it pernamently ? :) – Grzegorz Z Nov 28 '12 at 12:40
  • Post it as answer but please first in Your answer tell why we write it pernamently. I don't geret why we write here LookupListName_x003a_ID as pernamently value :) – Grzegorz Z Nov 28 '12 at 12:53
  • In my example it should be "Procent_x003a_Identyfikator" – Grzegorz Z Nov 28 '12 at 13:01

You can extend the ID column into the Child List from Lookup Fields... If you go to Site Settings -> Click lookup Column -> In section "Add a column to show each of these additional fields" check ID field!

Then in code you can access it like:


Replace "LookupListName" with the Lookup List's name in your case!

When you extend a column from Lookup field, the name of the field in your list becomes like: LookupListName:FieldName so if you extend ID field, the field name will be LookupListName:ID

Now when you access the fields in code, you need to use Internal Names and all the special characters are replaced by some code... code for ':' is 'x003a', so when you try to access the field in code you will write:
LookupListName_x003a_ID instead of LookupListName:ID

You can see complete code conversions here:
SharePoint Column/Field Display Names vs Internal Names

| improve this answer | |
        SPList list = web.Lists.TryGetList("Your list");
        SPListItem item = list.GetItemByID(ID);
        SPFieldLookupValue fieldLookupValue = new SPFieldLookupValue(item["FieldName"].ToString());
        int lookupID = fieldLookupValue.LookupId;
        string lookupValue = fieldLookupValue.LookupValue;
        item["TextFieldName"] = lookupValue

If I have understood the question correctly...

| improve this answer | |
  • And how get the fields in Event Receiver ? – Grzegorz Z Nov 28 '12 at 11:32
  • public override void ItemUpdated(SPItemEventProperties properties) { base.ItemUpdated(properties); SPListItem item = properties.ListItem; – Ralph W Nov 29 '12 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.