Pages

Wednesday, October 11, 2017

Find SharePoint List Column available via SharePoint Server Side Code



you can use Fields.ContainsField to check if the List Column exists from the custom List, So that, you can avoid error for running Custom Code Webpart.



if(reqReadlist.Fields.ContainsField("RequestID"))
{
  LogMessage("RequestID " + Reqitem["RequestID"], EventLogEntryType.Error);

  dr["Requisition No"] = Convert.ToString(Reqitem["RequestID"]);
}
else
{
    LogMessage("Not Available RequestID ", EventLogEntryType.Error);
}