I have stepped through and debugged my code and the id that is being passed to the
int id = parameter.ID;
CustomTableItemProvider provider = new CustomTableItemProvider(CMSContext.CurrentUser);
entity = provider.GetItem(id, TrainingPlanConstants.TrainingPlanTableName);
Strange because what you do seems correct, maybe the ID is not the ItemID in your custom table. You can debug it by looking into the database and run an query with this ID or check with the method GetItems() to see what the ItemID is.
Here is some more examples for Kentico 7 : http://devnet.kentico.com/docs/7_0/devguide/index.html?custom_tables_api_examples_managing_custom_table_data.htm
The workaround can be the GetItems methods as also is done in one the examples in the documentations. And if you use this parameters it is not so heavy for the performance :
string where = "YourIDColumn = " + id; int topN = 1; string columns = "ItemID"; DataSet dataSet = customTableProvider.GetItems(customTableClassName, where, null, topN, columns);
But I agree that it seems strange if you have the
GetItem method and you have the ID.
Good luck with debugging and finding your solution.