Deleting a custom table item

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

The code example on this page shows how an existing item can be deleted from a custom table.




using CMS.CMSHelper;

using CMS.SettingsProvider;

using CMS.SiteProvider;

using CMS.DataEngine;




        string customTableClassName = "customtable.SampleTable";


        // Get data class using custom table name

        DataClassInfo customTableClassInfo = DataClassInfoProvider.GetDataClass(customTableClassName);


        // Check if data class info exists

        if (customTableClassInfo != null)


            // Initialize custom table item provider with current user info and general connection

          CustomTableItemProvider ctiProvider = new CustomTableItemProvider(CMSContext.CurrentUser, ConnectionHelper.GetConnection());


            // Provide ID of item you want to delete

            int itemId = 1;


            // Get custom table item with given item ID

            CustomTableItem item = ctiProvider.GetItem(itemId, customTableClassInfo.ClassName);


            // Check if item exists

            if (item != null)


                // Delete item





Page url: