string customTableClassName = "custom.SampleTable";
// Get data class using custom table name
DataClassInfo customTableClassInfo = DataClassInfoProvider.GetDataClass(customTableClassName);
if (customTableClassInfo == null)
{
throw new Exception("Given custom table does not exist.");
}
// 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 edit
int itemId = 1;
// Get custom table item with given ID
CustomTableItem item = ctiProvider.GetItem(itemId, customTableClassInfo.ClassName);
// Set value of the custom table item field
item.SetValue("TestField", "Sample item");
// Update item
item.Update();
|