Foreign-Key Reference Demo

This sample demonstrates the RelationKind.ForeignKeyReference relation.

Features:

ForeignKeyReference-Country



The following code establishes the foreign-key relation.

                // Creating a Relation Descriptor.
                GridRelationDescriptor usStatesRd = new GridRelationDescriptor();
                usStatesRd.Name = "State";
                
                // Initialize it's RelationKind.
                usStatesRd.RelationKind = RelationKind.ForeignKeyReference;

                // Initialize it's ChildTable from the look-up name of SourceLIstSet.
                usStatesRd.ChildTableName = "USStates";  // SourceListSet name for lookup

                // Mention the file that establishes the relation.
                usStatesRd.RelationKeys.Add("State", "Key");

                // Making the relation as 'ReadOnly'.
                usStatesRd.ChildTableDescriptor.AllowEdit = false;
                usStatesRd.ChildTableDescriptor.AllowNew = false;   

                // Adding the relation descriptor to the MainTableDescriptor.
                mainTd.Relations.Add(usStatesRd);  

Foreign Key Helper

This sample also provides an option to use ForeignKeyHelper, a built-in helper class that can easily set up a ForeginKeyReference relation with a single method call.

GridForeignKeyHelper.SetupForeignTableLookUp(gridGroupingControl1, "Country", countries, "CountryCode", "CountryName");