Get column values of item in ItemAdding event handler

Posted: February 23, 2010 in Code, EventHandlers, Object Model

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
Comments
  1. srihari says:

    Thanks Dude…It’s working for me..

  2. SK says:

    Thanks for the “Internal Name” suggesstion

  3. N says:

    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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s