public override void ItemAdding(SPItemEventProperties properties)
{
base.ItemAdding(properties);
SPItem itemBeingAdded = properties.ListItem;
var startTime = itemBeingAdded["Start Time"];
// Some code goes here.
}
I am firing this event while adding an item in a calender list. It is getting fired. No problem. But I am not getting any value from properties
. In the above code startTime
gives me nothing. Actually, I want to access the column field of the item (properties
in my case) is being added.
When the user will click in save button, How can I get the column value in code behind (Inside the ItemAdding(SPItemEventProperties properties) method
). Let say, I need Start Time
and End Time
to compare them with some other values. Problem is in the ItemAdding
method. ItemUpdating is working fine.
public override void ItemUpdating(SPItemEventProperties properties)
{
base.ItemUpdating(properties);
SPItem itemBeingAdded = properties.ListItem;
var startTime = itemBeingAdded["Start Time"];
}
Finally, I got my answer from here. The way would be like following
string message = properties.AfterProperties["Description"].ToString();
Another thing is you should use internal name. For my case, display name didn't work.