Documentation > CMS Template API Library > Asset > GetPanels(String,SortOrder)

GetPanels

Get panels based on list name from data already saved into the asset. Note: The usual case is that the data for the panel comes from a List Panel on an input form. Once the form has been saved, this function will always return at least one entry, even if no data was entered on the panel. Therefore, you may want to check the data in the PanelEntry before using it, depending on the use case.

public List<PanelEntry> GetPanels(String,SortOrder)


Returns

The requested list of PanelEntries

Parameters

NameDescriptionType
panelName Name of the field on which to create the list System.String
sort Optional: sort order, default is null. If null, the list will be in the order it was saved. CrownPeak.CMSAPI.SortOrder

Code Example

C#

Sample:
List<PanelEntry> panels = asset.GetPanels("list_name");
foreach (PanelEntry entry in panels)
{
  Out.WriteLine("The value of list_field in this panel is: " + entry["list_field"]);
}

Connect with Crownpeak