Opendatasource with related tables

4 posts, 0 answers
  1. juance
    juance avatar
    16 posts
    Member since:
    Jul 2006

    Posted 14 Apr 2009 Link to this post

    I want to link the table territories (Northwindoa database) to a openaccessdatasource to add and modify records
    the territories,RegionID field  disappears and is required for linking controls to edition or insertion
    the list of fields in the openaccessdatasource are: TerritoryId, territorydescription, Region, Region.RegionID, and Region.RegionDescription.

    But Territory.RegionID not exist

    It is a mistake or am I doing something wrong

    I want link the openaccessdatasource to radgrid

    Thanks in advance



  2. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 17 Apr 2009 Link to this post

    Hello juance,

              The reason for the behavior you experience is that OpenAccess creates a reference as filed of the persistent classes for the relations between tables classes. For example the Territory table has a relation to the Region table. Hence, OpenAccess creates a Territory and Region classes and the Territory class has a reference field of type "Region".

             So, to access the RegionID field you use the following construction:  Territory.Region.RegionID. For insert statements though you should assign a Region object to the Territory like: territory.Region = myRegion. OpenAccess resolves the references in the lower layers and inserts the right values in the right collumns of the database tables.

    If you need any further instructions please do not hesitate to contact us back.

    Sincerely yours,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. juance
    juance avatar
    16 posts
    Member since:
    Jul 2006

    Posted 17 Apr 2009 Link to this post

    I have not explained well

    I have a radgrid linked to a openaccessdatasource with territory class
    When I link controls in the editing template  the territory.RegionID field of the table does not appear
    Therefore I can not insert or edit data
    I see only a Field Region and that is not  upgradable
    .
    I do not want to use code behind
  5. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 21 Apr 2009 Link to this post

    Hi juance,

    OpenAccess is not able to perform such operation without the use of code-behind. The related "Region" object should be assigned to the new "Territory" instance in the "Inserting" event handler of the OpenAccessDataSource.

    All the best,
    Zoran
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top