I have created an event receiver which will be executing after the item is added to the list.

I want to make the sub site based on the values entered in the list.

My event receiver code is:

    public override void ItemAdded(SPItemEventProperties properties)

        SPListItem item = properties.ListItem;
        string url = Convert.ToString(item[FieldNames.Url]);
        string title =Convert.ToString(item[FieldNames.ProjectName]);
        string desc = Convert.ToString(item[FieldNames.AboutProject]);
        SPWeb web = properties.Site.AllWebs.Add(url, title, desc, 1033, "Lf.Int#4", false, false);

In code FieldName class properties are for getting the internal names of fields.

I debugged the program and found url="" title="" desc="" i.e. I am not getting any value through item object. All things are null.

What am I missing?

  • Items in the list is being added from visual web part. – users1100 Oct 7 '13 at 6:37

Just to be sure, try to get the values from ItemUpdated event. Maybe the reason why that the values are not available is because they aren't exist yet.

|improve this answer|||||
  • @users1100, Did you get the values in ItemUpdated.? – Karthik Jaganathan Oct 7 '13 at 10:38
  • Yes,there was matter with the item adding. I added item values from visual web part and while adding event I used ListItem item = list.AddItem(); instead I did item=list.Items.Add() – users1100 Oct 8 '13 at 4:22

It seems you are not using internal names of the fields in the code. The follwoing post shows how to get internal names of the fields:


|improve this answer|||||
  • Tried using internal name also but still all values are null – users1100 Oct 7 '13 at 5:23

Remove base.ItemAdded(properties); and try properties.ListItem["InternalName"]

|improve this answer|||||
  • Thank you for reply sir, tried your way also but not working – users1100 Oct 7 '13 at 5:49
  • Can you try in item adding? let me know if it gives values there. – Ishan Oct 7 '13 at 5:59

You can check using properties.ListTitle to confirm whether this event fires when you add entry into your list. Because this event is common and it will be called for every list.

|improve this answer|||||
  • Yes, I am sure that the event is firing because I debugging it in Visual Studio by attaching process w3wp :-) – users1100 Oct 7 '13 at 6:03
  • Whether your properties has values for any columns in the list? – Suren Oct 7 '13 at 6:49
  • try setting EventFiringEnabled = false; before base.ItemAdded(properties); and EventFiringEnabled = true; at the end of the ItemAdded function. – Suren Oct 7 '13 at 6:54

Try with the


Ref: List Before and After properties

Hope this helps you.

|improve this answer|||||
  • Tried AfterProperties also sir. – users1100 Oct 7 '13 at 6:09
  • The values to the list is being added via visual web part, can it create problem – users1100 Oct 7 '13 at 6:28
  • @users1100, are you getting the ID value for properties.ListItemId ? – Karthik Jaganathan Oct 7 '13 at 6:54
  • Yes I can get item using the ListItemId – users1100 Oct 7 '13 at 7:01

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.