Get column values of item in ItemAdding event handler


In an Item Adding event handler Properties.ListItem will be null. Same is the case with Properties.BeforeProperties & Properties.AfterProperties too. So how to get the values entered in the NewForm.aspx in the ItemAdding method. Here we go..

You can access the value using AfterProperties property. But here you have to pass the internal name of the column whose value you want to access.

properties.AfterProperties[“Internal Name of the column”]

Or in case if you don’t know/want to explicitly specify the internal name you can get the same using Field.InternalName property. The below code snippet I used explains the same.

typeName  = Convert.ToString(site.Lists[properties.ListId].Fields[“Type Of Shoes”].InternalName);
allotedShoeType = Convert.ToString(properties.AfterProperties[typeName]);

Hope it helps..


Advertisements

3 thoughts on “Get column values of item in ItemAdding event handler

Add yours

  1. thanks you..
    really helpfull and straight forward..

    just got confused by what you mean on “Same is the case with Properties.BeforeProperties & Properties.AfterProperties too” yet in the end you give solution using the “Properties.AfterProperties”…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: