CodeSmith Community
Your Code. Your Way. Faster!

OneToOneViewRelationShip does not work without nesting the FormViews

Latest post 11-17-2006 6:09 AM by Tanno. 4 replies.
  • 11-16-2006 3:47 AM

    • Tanno
    • Top 100 Contributor
    • Joined on 10-06-2006
    • Posts 50
    • Points 1,215

    OneToOneViewRelationShip does not work without nesting the FormViews

    Got an insertpage working for a main table and two tables with 1-1 relationship using nested FormViews and OneToOneRelationships.

    As I understood from a comment from Bobby Diaz the same should also work without nesting as long as the FormViews and OneToOneRelationships are inside of the same NamingContainer.

    If this would work correctly it would be possible to replace the FormView by a MultiFormView with an InsertItemTemplatePath and reuse a generated usercontrol with input fields.

    However, an unnested version of the page where FormViews and OneToOneRelationships are placed inside a View fails to work.

     

    • Post Points: 35
  • 11-16-2006 10:06 AM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 735
    • Points 17,045

    Re: OneToOneViewRelationShip does not work without nesting the FormViews

    Tanno,

     You should be fine to use the OneToOneRelationships control. Can you post a sample ... we could help you to narrow the problem. Please also make sure you set the DataKeyNames for every FormView
     

    Tanno:

    Got an insertpage working for a main table and two tables with 1-1 relationship using nested FormViews and OneToOneRelationships.

    As I understood from a comment from Bobby Diaz the same should also work without nesting as long as the FormViews and OneToOneRelationships are inside of the same NamingContainer.

    If this would work correctly it would be possible to replace the FormView by a MultiFormView with an InsertItemTemplatePath and reuse a generated usercontrol with input fields.

    However, an unnested version of the page where FormViews and OneToOneRelationships are placed inside a View fails to work.

     

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 11-16-2006 12:33 PM In reply to

    • Tanno
    • Top 100 Contributor
    • Joined on 10-06-2006
    • Posts 50
    • Points 1,215

    Re: OneToOneViewRelationShip does not work without nesting the FormViews

    Mike thanks for your reply. The sample is below:

      <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
         <asp:View ID="View1" runat="server">

         <asp:FormView ID="BedrijfFormView" runat="server" DefaultMode="Insert" DataSourceID="BedrijfDataSource"
          DataKeyNames="BedrijfID">
          <InsertItemTemplate>
             ....SNIP....
          </InsertItemTemplate>
        </asp:FormView>
       
        <asp:FormView ID="BedrijfsProfielFormView" runat="server" DefaultMode="Insert" DataSourceID="BedrijfsProfielDataSource"
          DataKeyNames="BedrijfsProfielID">
          <InsertItemTemplate>
           ....SNIP...
          </InsertItemTemplate>
        </asp:FormView>
       
        <asp:FormView ID="ContactPersoonFormView" runat="server" DefaultMode="Insert" DataSourceID="ContactPersoonDataSource"
          DataKeyNames="ContactPersoonID">
          <InsertItemTemplate>
            ....SNIP...
          </InsertItemTemplate>
         
          <FooterTemplate>
            <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
              Text="Insert" />
            <asp:Button ID="CancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
              Text="Cancel" />
          </FooterTemplate>
        </asp:FormView>
       
        <data:OneToOneViewRelationship ID="BedrijfsProfielRelationship" runat="server">
          <PrimaryMember ID="PrimaryMember" runat="server" DataSourceID="BedrijfDataSource"
            EntityKeyName="BedrijfID" />
          <ReferenceMember ID="ReferenceMember" runat="server" DataSourceID="BedrijfsProfielDataSource"
            ViewControlID="BedrijfsProfielFormView" EntityKeyName="BedrijfsProfielID" ForeignKeyName="BedrijfID" />
        </data:OneToOneViewRelationship>
       
        <data:OneToOneViewRelationship ID="ContactPersoonRelationship" runat="server">
          <PrimaryMember ID="PrimaryMember1" runat="server" DataSourceID="BedrijfDataSource"
            EntityKeyName="BedrijfID" />
          <ReferenceMember ID="ReferenceMember1" runat="server" DataSourceID="ContactPersoonDataSource"
            ViewControlID="ContactPersoonFormView" EntityKeyName="ContactPersoonID" ForeignKeyName="BedrijfID" />
        </data:OneToOneViewRelationship>
       
        <data:BedrijfDataSource ID="BedrijfDataSource" runat="server" EnableTransaction="true">
        </data:BedrijfDataSource>
       
        <data:BedrijfsProfielDataSource ID="BedrijfsProfielDataSource" runat="server"  >
        </data:BedrijfsProfielDataSource>
       
        <data:ContactpersoonDataSource ID="ContactPersoonDataSource" runat="server"  >
        </data:ContactpersoonDataSource>
      
        </asp:View>
        </asp:MultiView>

    • Post Points: 35
  • 11-16-2006 1:11 PM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 735
    • Points 17,045

    Re: OneToOneViewRelationShip does not work without nesting the FormViews

    Tanno,

    From what i understand the relationship controls do not work with MultiView and in order to achieve single-click update call, children controls have to be nested.

    Check that thread http://community.codesmithtools.com/forums/thread/16533.aspx

    Mike Shatny
    --------------------------------------------------------------
    Member of the .netTiers team http://www.nettiers.com
    --------------------------------------------------------------

    • Post Points: 35
  • 11-17-2006 6:09 AM In reply to

    • Tanno
    • Top 100 Contributor
    • Joined on 10-06-2006
    • Posts 50
    • Points 1,215

    Re: OneToOneViewRelationShip does not work without nesting the FormViews

    Hi Mike

    Let me tell you my observations:

    Nesting only the FormViews and leaving the OneToOneViewRelationships outside the nested FormViews works correctly.

    Putting everything inside a MultiView does not make a difference, it remains working correctly. 

    Getting a single-click insert for the FormViews cannnot be the reason that nesting of the FormViews is necessary, since I could get also a single-click insert by calling all three FormView.InsertItem() methods within a button OnClick event, but that doesn't not work.

    First I thought that the problem might perhaps have to do with event order that needs to be nested, so I placed the FormView.InsertItem() methods of the related tables within the OnItemInserted event of the insert button of the FormView of the main table.    

    But that also doesn't work, and the reason why it wouldn't work remains unclear to me.

    It can't be a scope problem can it ?

    regards

    Tanno

     

    • Post Points: 5
Page 1 of 1 (5 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems