The code example on this page shows how an existing item can be deleted from a custom table.
[C#]
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 item.Delete(); } } |
Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_deleting_a_custom_table_item.htm