I've been having trouble with programmatically changing the behavior of a field in SharePoint. Suppose I have a list called PROJECTS with project names and etc. Then I create another list called PROGRESS. Now, I have a "lookup" field on the NewForm.aspx to add a project from the PROJECT list with various开发者_如何学运维 notes/details to the PROGRESS list pertaining to the project picked from the dropdown (lookup field).
Here is the twist -- some projects are manually edited to indicate that they've been closed. For instance, we have "Project A", "Project B", and "Project C." So then we close the first. Now we should have "[closed] Project A", "Project B", "Project C". My goal is to be able to parse out the projects with the titles starting with '[closed]'. That is all.
I'm very new to SharePoint and .Net.. In any case, I don't really know where to go from here:
SPSite rootSite = new SPSite("http://localhost");
SPWeb web = rootSite.AllWebs["ProjectSite"];
SPList progress = web.Lists["PROGRESS"];
SPListItemCollection progressItems = progress.Items;
foreach (SPItem item in progressItems)
{
//What do I do next? (Note: Played with SPField and SPLookup classes with no luck.)
}
Doing more research on the subject matter in the meantime -- thanks for your time.
If you want to change the value in the lookup field ,you need to change the value in refernced list,not to your list item. For eg: if your lookup field is referencing "x" list,change the value with prefixing closed tag..
精彩评论