Click here to Skip to main content
15,904,023 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

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";
itemtoinsert.Update();

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
Updated 14-Dec-12 2:16am
v3

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900