Answers for "Kentico 9 - Loading data records from a custom table"

C#
0

Kentico 9 - Loading data records from a custom table

// Prepares the code name (class name) of the custom table
string customTableClassName = "customtable.sampletable";

// Gets the custom table
DataClassInfo customTable = DataClassInfoProvider.GetDataClassInfo(customTableClassName);
if (customTable != null)
{
    // Gets a custom table record with a specific primary key ID (25)
    CustomTableItem item1 = CustomTableItemProvider.GetItem(25, customTableClassName);

    // Gets the first custom table record whose value in the 'ItemName' field is equal to "SampleName"
    CustomTableItem item2 = CustomTableItemProvider.GetItems(customTableClassName)
                                                        .WhereEquals("ItemName", "SampleName")
                                                        .FirstObject;

    // Loads a string value from the 'ItemText' field of the 'item1' custom table record
    string itemTextValue = ValidationHelper.GetString(item1.GetValue("ItemText"), "");
}
Posted by: Guest on June-25-2021

Code answers related to "Kentico 9 - Loading data records from a custom table"

C# Answers by Framework

Browse Popular Code Answers by Language