CodeSmith Community
Your Code. Your Way. Faster!

ManyToManyListRelationship Cannot get working....

Latest post 01-12-2007 2:47 PM by mike123. 11 replies.
  • 11-30-2006 9:55 AM

    • chrisbond
    • Top 150 Contributor
    • Joined on 12-02-2003
    • Hereford, United Kingdom
    • Posts 36
    • Points 810

    ManyToManyListRelationship Cannot get working....

    Got the following:

         <data:EntityGridView ID="egvSearch" runat="server" AutoGenerateColumns="False"                   
                DataSourceID="dsOrders"
                DataKeyNames="OrderId"
                AllowMultiColumnSorting="False"
                DefaultSortDirection="Ascending"   
                ExcelExportFileName="Export_Orders.xls" 
                AllowSorting="True"
                AllowPaging="True" AllowExportToExcel="True" ExportToExcelText="Excel" PageSelectorPageSizeInterval="10">
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="OrderId" HeaderText="OrderId" SortExpression="OrderId" />
                    <asp:BoundField DataField="OrderDate" HeaderText="Date" SortExpression="OrderDate" />
                    <asp:BoundField DataField="TotalPrice" HeaderText="Total" SortExpression="TotalPrice" />               
                    <asp:BoundField DataField="OrderStatusId" HeaderText="Status" SortExpression="OrderStatusId" />
                </Columns>
                <EmptyDataTemplate>
                    <b>No Orders Found!</b>
                </EmptyDataTemplate>
        </data:EntityGridView>

         <data:OrdersDataSource ID="dsOrders" runat="server" SelectMethod="GetByAccountId">
            <Parameters>
                <asp:QueryStringParameter Type="String" Name="AccountId" QueryStringField="Id"></asp:QueryStringParameter>
            </Parameters>
        </data:OrdersDataSource>

     What I would like todo is in the columns field instead of showing OrderStatusId show what OrderStatusId is.  This is a FK from Orders.OrderStatusId to OrderStatusType.OrderStatusId - How would I go about showing OrderStatusDescription from the OrderStatusType linked?

     
    Kind Regards,
    Chris Bond

     

    • Post Points: 35
  • 11-30-2006 10:52 AM In reply to

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

    Re: ManyToManyListRelationship Cannot get working....

    Chris,

     Try this:

         <data:EntityGridView ID="egvSearch" runat="server" AutoGenerateColumns="False"                  
                DataSourceID="dsOrders"
                DataKeyNames="OrderId"
                AllowMultiColumnSorting="False"
                DefaultSortDirection="Ascending"  
                ExcelExportFileName="Export_Orders.xls"
                AllowSorting="True"
                AllowPaging="True" AllowExportToExcel="True" ExportToExcelText="Excel" PageSelectorPageSizeInterval="10">
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="OrderId" HeaderText="OrderId" SortExpression="OrderId" />
                    <asp:BoundField DataField="OrderDate" HeaderText="Date" SortExpression="OrderDate" />
                    <asp:BoundField DataField="TotalPrice" HeaderText="Total" SortExpression="TotalPrice" />              

    [edit] instead of this:
                    <asp:BoundField DataField="OrderStatusTypeIdSource.OrderStatusDescription" HeaderText="Status"/>

    it should be:

                    <asp:TemplateField HeaderText="Status">
                        <ItemTemplate>                       
                            <%# Eval("
    OrderStatusIdSource.OrderStatusDescription") %>
                        </ItemTemplate>
                    </asp:TemplateField>

    [end edit]
                </Columns>
                <EmptyDataTemplate>
                    <b>No Orders Found!</b>
                </EmptyDataTemplate>
        </data:EntityGridView>

         <data:OrdersDataSource ID="dsOrders" runat="server" SelectMethod="GetByAccountId">
        <DeepLoadProperties Method="IncludeChildren" Recursive="false">
            <Types>
                 <data:OrdersProperty Name="OrderStatusType" />
            </Types>
        </DeepLoadProperties>   
     
        <Parameters>
                <asp:QueryStringParameter Type="String" Name="AccountId" QueryStringField="Id"></asp:QueryStringParameter>
        </Parameters>
        </data:OrdersDataSource>
     

    chrisbond:

    Got the following:

         <data:EntityGridView ID="egvSearch" runat="server" AutoGenerateColumns="False"                   
                DataSourceID="dsOrders"
                DataKeyNames="OrderId"
                AllowMultiColumnSorting="False"
                DefaultSortDirection="Ascending"   
                ExcelExportFileName="Export_Orders.xls" 
                AllowSorting="True"
                AllowPaging="True" AllowExportToExcel="True" ExportToExcelText="Excel" PageSelectorPageSizeInterval="10">
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="OrderId" HeaderText="OrderId" SortExpression="OrderId" />
                    <asp:BoundField DataField="OrderDate" HeaderText="Date" SortExpression="OrderDate" />
                    <asp:BoundField DataField="TotalPrice" HeaderText="Total" SortExpression="TotalPrice" />               
                    <asp:BoundField DataField="OrderStatusId" HeaderText="Status" SortExpression="OrderStatusId" />
                </Columns>
                <EmptyDataTemplate>
                    <b>No Orders Found!</b>
                </EmptyDataTemplate>
        </data:EntityGridView>

         <data:OrdersDataSource ID="dsOrders" runat="server" SelectMethod="GetByAccountId">
            <Parameters>
                <asp:QueryStringParameter Type="String" Name="AccountId" QueryStringField="Id"></asp:QueryStringParameter>
            </Parameters>
        </data:OrdersDataSource>

     What I would like todo is in the columns field instead of showing OrderStatusId show what OrderStatusId is.  This is a FK from Orders.OrderStatusId to OrderStatusType.OrderStatusId - How would I go about showing OrderStatusDescription from the OrderStatusType linked?

     
    Kind Regards,
    Chris Bond

     

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

    • Post Points: 35
  • 01-11-2007 5:00 PM In reply to

    • mousse
    • Top 150 Contributor
    • Joined on 10-03-2006
    • Posts 27
    • Points 755

    Re: ManyToManyListRelationship Cannot get working....

     

    I'm trying to do much the same thing and i must be missing something.

    I'm not using quite the same tables, but their relationship is the same.. Inside the data:MAINTABLEdatasource tag, I make a data:MAINTABLEproperty tag, and its' intellisense provides suggestions.. i choose the one that is literally the name of the lookup table i want (KEYTABLE), in the above scenario, "OrderStatusType".

    but i still fail to get the logic behind the proper construction of the asp:BoundField tag within the gridview's columns. how does one arrive at "OrderStatusTypeIdSource.OrderStatusDescription"? I don't see where the "IDsource" part comes from, nor does just playing around with this seem seem to be getting me anywhere.

    doing the reverse works fine. within a datasource-deeploadproperties tag for the KEYTABLE is provided a MAINTABLEdatasource, and i can reference that to a subdatagrid's datasource with ease. I'm at a loss for how to use this nondatasource deeploadproperty provided by my maintable.

     

     

    • Post Points: 35
  • 01-12-2007 1:59 AM In reply to

    • chrisbond
    • Top 150 Contributor
    • Joined on 12-02-2003
    • Hereford, United Kingdom
    • Posts 36
    • Points 810

    Re: ManyToManyListRelationship Cannot get working....

    I never got this working in the end - from reading the forums at the time I believe it may have been a bug not sure if they've fixed the main release might only been in source control tree.
    • Post Points: 35
  • 01-12-2007 9:58 AM In reply to

    • mousse
    • Top 150 Contributor
    • Joined on 10-03-2006
    • Posts 27
    • Points 755

    Re: ManyToManyListRelationship Cannot get working....

    I wonder if OrderStatusTypeIdSource is a custom exposed entity as in this thread:
    http://community.codesmithtools.com/forums/thread/21322.aspx

    still then, I'm failing to understand the proper use of any data:TABLEproperty that doesn't end in "source".

     

     

    • Post Points: 35
  • 01-12-2007 10:14 AM In reply to

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

    Re: ManyToManyListRelationship Cannot get working....

    .netTiers will generate extra properties for every entity, based on their relationships to other entities.
    In the above example Order's table relation to OrderStatus is many-to-one, therefore OrderStatusTypeIdSource property exists. That property is populated using deepload approach.

     

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

    • Post Points: 35
  • 01-12-2007 11:21 AM In reply to

    • mousse
    • Top 150 Contributor
    • Joined on 10-03-2006
    • Posts 27
    • Points 755

    Re: ManyToManyListRelationship Cannot get working....

    ... time for me to get more concrete. I'm sorry I don't use the same tables, but the relationship should be the same.

                <asp:GridView runat="server" ID="dsOrderDetails" DataSourceID="dd2" AutoGenerateColumns="false" >
                <Columns>
    <asp:BoundField DataField="TluLeadStatusIdSource.lsleadStatusDesc" HeaderText="Status" SortExpression="ls_leadStatusDesc" />
                </Columns>
                </asp:GridView>                   
               
                <data:TLeadDataSource ID="dd2" runat="server" SelectMethod="getAll" EnableDeepLoad="true">
                <DeepLoadProperties><Types>
                    <data:TLeadProperty Name="TluLeadStatus" />
                </Types></DeepLoadProperties>
                </data:TLeadDataSource>
     

    t_lead.le_leadStatusID is a foreign key to tlu_LeadStatus.ls_leadStatusID trying to reference ls_leadStatusDesc. 

    the above code yields "A field or property with the name 'TluLeadStatusIdSource.lsleadStatusDesc' was not found on the selected data source."

    Nor do I see the relation between constructing the datasource's deepload property and the boundfield's datafield setting.

     

    To edit something i said earler:

    "I'm failing to understand the proper use of any data:TABLEproperty that doesn't end in 'source'."

     I meant to say "....doesn't end in 'collection'."
     

     

    • Post Points: 35
  • 01-12-2007 12:08 PM In reply to

    • mousse
    • Top 150 Contributor
    • Joined on 10-03-2006
    • Posts 27
    • Points 755

    Re: ManyToManyListRelationship Cannot get working....

     

    Oh, FYI, in case it matters--though for this example I'm filling boundfields in a datagrid, the true intention I have for this is to display the value in a label for a formview's noneditable itemtemplate, whereas the edititemtemplate and insertitemtemplates use dropdownlists bound as in the autogenerated examples.

     I could well just create a view and be on to other problems, but it strikes me as odd to have to do so for every table that has simple lookup values.
     

    • Post Points: 5
  • 01-12-2007 1:26 PM In reply to

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

    Re: ManyToManyListRelationship Cannot get working....

    mousse,

     

    Please try templatefield instead BoundField:

    <asp:GridView runat="server" ID="dsOrderDetails" DataSourceID="dd2" AutoGenerateColumns="false" >
                <Columns>
                    <asp:TemplateField HeaderText="Status">
                        <ItemTemplate>                       
                            <%# Eval("TluLeadStatusIdSource.lsleadStatusDesc") %>
                        </ItemTemplate>
                    </asp:TemplateField>

                </Columns>
                </asp:GridView>                  
              
                <data:TLeadDataSource ID="dd2" runat="server" SelectMethod="getAll" EnableDeepLoad="true">
                <DeepLoadProperties><Types>
                    <data:TLeadProperty Name="TluLeadStatus" />
                </Types></DeepLoadProperties>
                </data:TLeadDataSource>

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

    • Post Points: 35
  • 01-12-2007 1:49 PM In reply to

    • mousse
    • Top 150 Contributor
    • Joined on 10-03-2006
    • Posts 27
    • Points 755

    Re: ManyToManyListRelationship Cannot get working....

    This yields the error i expect, no such subdata:

    DataBinding: '[projname].Entities.TLead' does not contain a property with the name 'TluLeadStatusIdSource'.

     
    I'm using the dec6 net2.0 templates, the tables definetly have the relationships neccessary..

    i can't find the results of specifying the tluleadstatus tleadproperty at all.

    nor do i follow how i'm supposed to know to append "[TABLE]idsource" when wanting to reference it; wouldn't the code for the tleadproperty have name="TluLeadStatusIdSource" for there to be an object of that name to reference?

     

    i'm tremendously indebted to y'all for this great project and all the help you offer here, thanks again.

     

    • Post Points: 5
  • 01-12-2007 2:15 PM In reply to

    • mousse
    • Top 150 Contributor
    • Joined on 10-03-2006
    • Posts 27
    • Points 755

    Re: ManyToManyListRelationship Cannot get working....

     

    HA! got it! it's just [foriegnkeyname]source. that's why i got confused, the table name isn't involved.

     
    <%# Eval("LeLeadStatusIDSource.lsleadStatusDesc")%> 

    I browsed through the tlead object more thoroughly and found it.

    thanks again for your time 

    • Post Points: 35
  • 01-12-2007 2:47 PM In reply to

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

    Re: ManyToManyListRelationship Cannot get working....

    Awesome!

    I have corrected few things in my initial response to chrisbond which probably got him and you confused

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

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