SPList help
Windows Server Forum Index Windows Server
Server discussion on Windows platform.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web winserverhelp.com
SPList help

 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development
Author Message
jrmcdona
Guest





Posted: Fri Jan 14, 2005 10:41 pm    Post subject: SPList help Reply with quote

Can somebody please show me how to get the value for
AllWebs["Destination_Site"]? I cannot seem to get the correct value for my
site which is http://localhost/sites/myteamsite and the name is "My Team
Site". The Destination list i am using is called "Events". Thanks a bunch!

I am using the following code:
SPSite site = SPControl.GetContextSite(Context);

SPList destList =
site.AllWebs["Destination_Site"].Lists["Destination_List"];

SPListItemCollection listItems = destList.Items;

SPListItem newItem = listItems.Add();

newItem["Field1_Name"] = "Scenario 2";
newItem["Field2_Name"] = 45;
newItem["Field3_Name"] = "A sample note for this item.";

newItem.Update();
Back to top
jrmcdona
Guest





Posted: Sat Jan 15, 2005 1:13 am    Post subject: RE: SPList help Reply with quote

So I was able to hard code the value for AllWebs["/sites/myteamsite"]
however, is there no method to retrieve this value dynamically?? My web part
will not know what site the user is on.

thanks for your time!

jordan


"jrmcdona" wrote:

Quote:
Can somebody please show me how to get the value for
AllWebs["Destination_Site"]? I cannot seem to get the correct value for my
site which is http://localhost/sites/myteamsite and the name is "My Team
Site". The Destination list i am using is called "Events". Thanks a bunch!

I am using the following code:
SPSite site = SPControl.GetContextSite(Context);

SPList destList =
site.AllWebs["Destination_Site"].Lists["Destination_List"];

SPListItemCollection listItems = destList.Items;

SPListItem newItem = listItems.Add();

newItem["Field1_Name"] = "Scenario 2";
newItem["Field2_Name"] = 45;
newItem["Field3_Name"] = "A sample note for this item.";

newItem.Update();
Back to top
 
Post new topic   Reply to topic    Windows Server Forum Index -> Portal Server Development All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




New Topics Powered by phpBB