CodeSmith Community
Your Code. Your Way. Faster!

EntityDataSourceFilter inside DetailsView

Latest post 05-21-2007 11:56 PM by Thiago. 2 replies.
  • 05-16-2007 7:25 AM

    • Thiago
    • Not Ranked
    • Joined on 05-16-2007
    • Posts 2
    • Points 40

    EntityDataSourceFilter inside DetailsView

    Hello, people!

    I'm just about to finish a project, but I am stuck at something that, hopefully, is somthing silly I am missing...

    I have a DetailsView attached to an ObjectDataSource (the DataSource was created with NetTiers, if this is relevant information). I can't make it work as desired if the DataSource returns only one record, but nothing wrong happens with two or more. In the particular case in which i have only one record and try to call any functionality, I receive the error message "Databind methods such as Bind(), Eval() and XPath() are only allowed in the context of a DataBound Control" (I can't remember if these are the actual words, but that's the spirit).

     
    This is how the Filter is used inside the DetailsView:


                                <asp:TemplateField HeaderText="AddressType">
                                    <ItemTemplate>
                                        <asp:Repeater runat="server" ID="rptAddressType"
                                            DataSourceID="AddressTypeFilter">
                                            <ItemTemplate>
                                                 <%# Eval("TypeName") %>
                                            </ItemTemplate>   
                                        </asp:Repeater>

                                        <data:EntityDataSourceFilter runat="server"
                                            ID="AddressTypeFilter"
                                            DataSourceID="AddressTypeDataSource"
                                            EnableViewState="true"
                                            Filter='<%# String.Format("AddressTypeSeq = {0}", Eval("AddressTypeSeq")) %>'
                                        />

                                        <data:AddressTypeDataSource runat="server"
                                            ID="AddressTypeDataSource" SelectMethod="GetAll">
                                        </data:AddressTypeDataSource>
                                       
                                    </ItemTemplate>
                                </asp:TemplateField>

     As I said before - the strange thing is that it works sometimes, others it doesn't, and I still couldn't figure out why... Can anyone help me?

     
    Thank you,

    Thiago. 

    • Post Points: 35
  • 05-17-2007 11:57 AM In reply to

    • mike123
    • Top 10 Contributor
    • Joined on 02-25-2005
    • Toronto, Ontario
    • Posts 726
    • Points 16,910

    Re: EntityDataSourceFilter inside DetailsView

    Thiago,

    Try using DeepLoad method instead, to get the AddressType, see the example bellow:

    <asp:DetailsView runat="server" ID="DetailsView" DataSourceID="CustomersDataSource"
        AllowPaging="true" AutoGenerateRows="True"
    >
    <Fields>
        <asp:TemplateField HeaderText="AddressType">
            <ItemTemplate>
                <asp:Repeater runat="server" ID="rptAddressType"
                    DataSource='<%# Eval("OrdersCollection")%>'>
                    <ItemTemplate>
                         <%# Eval("OrderDate")%>
                    </ItemTemplate>  
                </asp:Repeater>         
            </ItemTemplate>
        </asp:TemplateField>
       
    </Fields>
    </asp:DetailsView>

    <data:CustomersDataSource ID="CustomersDataSource" runat="server"
        SelectMethod="GetAll" EnableDeepLoad="true"
    >
    <DeepLoadProperties Method="IncludeChildren" Recursive="False">
         <Types>
            <data:CustomersProperty Name="OrdersCollection"/>
        </Types>
    </DeepLoadProperties>
    </data:CustomersDataSource>

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

    • Post Points: 35
  • 05-21-2007 11:56 PM In reply to

    • Thiago
    • Not Ranked
    • Joined on 05-16-2007
    • Posts 2
    • Points 40

    Re: EntityDataSourceFilter inside DetailsView

    I tried to, but an attempt to load the page returns me another databinding error - the entity does not contains a propoerty with the name "OrdersCollection" (or whatever name I set)...
    • Post Points: 5
Page 1 of 1 (3 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems