using (SPSite site = new SPSite("SiteURL"))
{
using (SPWeb web = site.OpenWeb())
{
SPList projectGeneral = web.Lists["ListName"];
for (int i = 0; i < projectGeneral.Fields.Count;i++ )
try
{
Console.WriteLine(projectGeneral.Fields[i].Title);
projectGeneral.Fields[i].ShowInNewForm = null;
projectGeneral.Fields[i].ShowInDisplayForm = null;
projectGeneral.Fields[i].ShowInEditForm = null;
projectGeneral.Fields[i].ShowInViewForms = null;
projectGeneral.Fields[i].Update();
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.Message);
}
Console.WriteLine("Press Enter Key");
Console.ReadLine();
}
}
{
using (SPWeb web = site.OpenWeb())
{
SPList projectGeneral = web.Lists["ListName"];
for (int i = 0; i < projectGeneral.Fields.Count;i++ )
try
{
Console.WriteLine(projectGeneral.Fields[i].Title);
projectGeneral.Fields[i].ShowInNewForm = null;
projectGeneral.Fields[i].ShowInDisplayForm = null;
projectGeneral.Fields[i].ShowInEditForm = null;
projectGeneral.Fields[i].ShowInViewForms = null;
projectGeneral.Fields[i].Update();
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.Message);
}
Console.WriteLine("Press Enter Key");
Console.ReadLine();
}
}
No comments:
Post a Comment