Thanks for the response...
The primary key doesn't always start at 1 as users will delete items. As you can see in the image below, it's currently starting at 30. And the item I have selected in Kentico is CourseID 41 in the database. Then next item up is 46. Also, items 30 to 40 isn't even under Professional Firefighting... It has a completely different parent. I need to know which item user has currently selected in the Kentico tree (even if user has re-arranged them in the tree) by CourseID (primary key) so that I can find the related values in other columns (CourseName, CourseSnippet, etc).
SqlParameter courseIDParameter = new SqlParameter("@courseIDParameter", SqlDbType.Int, 4);
courseIDParameter.Value = CurrentDocument.GetValue("CourseID");
SqlCommand myCommand = new SqlCommand("SELECT * FROM CourseTable WHERE CourseID = @courseIDParameter", myConnection);
Which assembly is DocumentForeignKeyValue from? I am using Kentico 11. And I inherit from CMSAbstractLayoutWebPart.
Can you show me an example of how you would use DocumentForeignKeyValue in CourseForm.ascx.cs to retrieve CourseID or CourseName of the selected item?