Getting items from a custom table

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following code example shows how a DataSet with data items stored in a custom table can be retrieved.

 

[C#]

 

using System.Data;

using CMS.CMSHelper;

using CMS.SiteProvider;

 

...

 

        string customTableClassName = "customtable.SampleTable";

        string where = "ItemID > 5";

        string orderBy = "ItemOrder";

        int topN = 10;

        string selectedColumns = "ItemID, ItemCreatedBy, ItemModifiedBy";

 

        // Create an instance of the Custom table item provider

        CustomTableItemProvider tableProvider = new CustomTableItemProvider(CMSContext.CurrentUser);

 

        // Get a list of custom table items according to a WHERE condition

        DataSet ds = tableProvider.GetItems(customTableClassName, where, orderBy);

 

        DataSet ds2 = tableProvider.GetItems(customTableClassName, where, orderBy, topN, selectedColumns);

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_getting_items_from_a_custom_table.htm