Click here to Skip to main content
13,557,915 members
Rate this:
Please Sign up or sign in to vote.
See more:

I am new to SharePoint and needed some help in the below listed scenario

I have a web app in the below shown structure

Web App->Site Collection 1
Subsite 1
Subsite 2
Subsite 3
->Subsite 1 under Subsite 3
-> List 1(Claims)under

(3 Site collections,Under Site Collection 2

Now my challenge is I have to inster an item programatically into List 2

I have used this code which is not able to find Subsite 1

using (SPSite site = SPContext.Current.Site)
using (SPWeb web = SPContext.Current.Web)

web.AllowUnsafeUpdates = true;

SPList claimlist = web.Lists["Claims"]; SPListItem itemtoinsert = claimlist.Items.Add();
itemtoinsert["title"] = "december expense";
itemtoinsert["status"] = "submitted";

web.AllowUnsafeUpdates = false;


When I debug with breakpoints I get the error at the line in bold List is not found.

Any help is very much appreciated.

Thank You!
Posted 14-Dec-12 2:09am
Updated 14-Dec-12 2:16am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.180515.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100