string DURL = "http://myURL/";
using (SPSite site = new SPSite(DURL))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;
SPList listLook = web .Lists ["Posts"];
SPList list = web.Lists["Comments"];
SPListItem Item1 = list.Items.Add();
Item1["Title"] = "My testing title";
Item1.Fields["Post Id"].ReadOnlyField = false;
Item1["Post Id"] = 1;
Item1.Update();
Item1.Fields["Post Title"].ReadOnlyField = true;
Item1.Fields["Post Id"].ReadOnlyField = true;
}
}
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.