locked
many-to-many DynamicField causing PageRequestManagerServerErrorException RRS feed

  • Question

  • User-1712241964 posted

    REALLY making me scratch my head…..
    I have a page that has a DetailsViews on it, outside of an UpdatePanel.   I have a GridView with a DetailsViews attached to it’s select, to view details, obviously.   This GridView/DetailsView are in the UpdatePanel.   All are using EntityDataSources.
    All controls use DynamicFields exclusively(no BoundFields)….if that even matters.
    All works wonderfully and as expected until I do one thing…
    Add:

     <asp:DynamicField DataField="PlayerPositions" HeaderText="Positions" />

     to the DetailsView on the page that is not within the UpdatePanel.
    Upon adding this, the “PlayerPositions” field properly displays the many-to-many data as expected, but a script err gets thrown when “Select” is clicked within the GridView within the UpdatePanel:
    Message: Sys.WebForms.PageRequestManagerServerErrorException: The DynamicHyperLink control 'DynamicHyperLink1' could not determine the MetaTable to base the link on. Make sure that the the control is in a page that is in the context of a Dynamic Data route or that the ContextTypeName and TableName properties are set correctly.

    I am able to duplicate the behavior removing UpdatePanel from equasion.
    And, of course, unlike LinqDataSource, EntityDataSource does not have a property named 'TableName'.
    As always… and suggestion at all would be appreciated greatly.

    Thanks,
    Gary

    Thursday, September 15, 2011 8:52 AM

Answers

  • User-1712241964 posted

    found it!
    I had turned scaffolding off for 'PlayerPositions' because I wanted to display the values but not have them be used for navigation(not hyperlinked).
    changed:

    [MetadataType(typeof(PlayerPositionsMetadata))]
            [DisplayName("Player Positions")]
            [ScaffoldTable(false)]
            public partial class PlayerPositions

    to:

    [MetadataType(typeof(PlayerPositionsMetadata))]
            [DisplayName("Player Positions")]
            //[ScaffoldTable(false)]
            public partial class PlayerPositions

    I'll mark this post as the 'answer', as removing this attribute removes the 'breakage', but I'm still at a loss as to why it has the effect in this instance and will search for an alternate method by which to disable the navigation.
    Thanks again to all who gave this issue thought and chimed in!

    -Gary

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 22, 2011 11:06 AM

All replies

  • User-330204900 posted

    I don't know why this would happen but all my controls are in update pannels and if you notice they are in the update pannel in all the default pages, give it a try and see if putting it in an update pannel fixes the issue.

    Friday, September 16, 2011 3:50 AM
  • User3866881 posted

    Hello gstadter:)

    Would you mind showing us your full codes? How did you design your aspx and cs codes?

    We cannot reproduce your issue……

    Friday, September 16, 2011 9:37 PM
  • User-1712241964 posted

    tried wrapping them in UpdatePanel. ...did not change behavior.

    here is the aspx page WITH the conflicting DynamicField:
    (the codebehind is default/empty)

    <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:DynamicDataManager ID="DynamicDataManager1" runat="server" >
            <DataControls>
                <asp:DataControlReference ControlID="GridView1" />
                <asp:DataControlReference ControlID="DetailsView1" />
                <asp:DataControlReference ControlID="DetailsView2" />
            </DataControls>
            </asp:DynamicDataManager>
    
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
             <asp:DetailsView ID="DetailsView2" runat="server" DataSourceID="RostersDS" 
                Width="200px" GridLines="None" DataMember="Rosters" AutoGenerateRows="False">
                  <Fields>
                   <asp:DynamicField DataField="Teams" AllowNavigation="false" HeaderText="Team" />
                      <asp:DynamicField DataField="Number" />
                      <asp:DynamicField DataField="Grade" />
                      <asp:DynamicField DataField="HighlightLink" HeaderText="" UIHint="HighlightFootageUrl" />
                      <asp:DynamicField DataField="PlayerPositions" />
                   </Fields>
            </asp:DetailsView>
                    <asp:EntityDataSource ID="RostersDS" runat="server" ContextTypeName="FBDBModel.FBDBEntities"
                AutoGenerateWhereClause="True" ConnectionString="name=FBDBEntities" 
                DefaultContainerName="FBDBEntities" EnableFlattening="False" 
                EntitySetName="Rosters" Where="" Include="Players,Teams,GamePlayerStats,PlayerPositions">
                <WhereParameters>
                    <asp:QueryStringParameter Name="RosterID" QueryStringField="RID" Type="Int32" />
                </WhereParameters>
            </asp:EntityDataSource>
            </ContentTemplate>
            </asp:UpdatePanel>
          
            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  
                DataKeyNames="GamePlayerStatID" DataSourceID="EntityDataSource1" CellPadding="4" ForeColor="#333333" 
                GridLines="None" AutoGenerateSelectButton="True" 
                EnablePersistedSelection="True" ViewStateMode="Enabled">
                    <AlternatingRowStyle BackColor="White" />
                    <Columns>
                        <asp:DynamicField DataField="Games"/>
                    </Columns>
                    <EditRowStyle BackColor="#2461BF" />
                    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#EFF3FB" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />
                </asp:GridView>
                <asp:EntityDataSource ID="EntityDataSource1" runat="server" ContextTypeName="FBDBModel.FBDBEntities" 
                    AutoGenerateWhereClause="True" ConnectionString="name=FBDBEntities" 
                    DefaultContainerName="FBDBEntities" EnableFlattening="False" 
                    EntitySetName="GamePlayerStats" Where="">
                    <WhereParameters>
                        <asp:QueryStringParameter Name="RosterID" QueryStringField="RID" Type="Int32" DefaultValue="2" />
                    </WhereParameters>
                </asp:EntityDataSource>
    
    
                <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" 
                    AutoGenerateRows="False" DataKeyNames="GamePlayerStatID" 
                    DataSourceID="EntityDataSource2">
                    <Fields>
                        <asp:DynamicField DataField="Int_Int" />
                    </Fields>
                </asp:DetailsView>
                <asp:EntityDataSource ID="EntityDataSource2" runat="server" ContextTypeName="FBDBModel.FBDBEntities" 
                    ConnectionString="name=FBDBEntities" DefaultContainerName="FBDBEntities" 
                    EnableFlattening="False" EntitySetName="GamePlayerStats" 
                AutoGenerateWhereClause="True" Where="" ViewStateMode="Enabled">
                    <WhereParameters>
                        <asp:ControlParameter ControlID="GridView1" Name="GamePlayerStatID" 
                            PropertyName="SelectedValue" />
                    </WhereParameters>
                </asp:EntityDataSource>
            </ContentTemplate>
            </asp:UpdatePanel>

    as is, the "PlayerPositions" properly renders the FK information but makes the page throw the error when "Select" is clicked in the GridView.
    If the "PlayerPositions" DynamicField is removed, DetailsView1 is updated each time a row is selected in the GridView.

     

    Monday, September 19, 2011 7:56 AM
  • User3866881 posted

    <asp:DynamicField DataField="PlayerPositions" />

    So you mean "PlayerPositions" is a foreign key or somethign else?

    Show us your model classes, please?

    Monday, September 19, 2011 9:03 PM
  • User-1712241964 posted

    yes sir, Decker.   It is a many-to-many.

    Please let me know if the info in the attached images is not what you were referring to(were you referring to the C#?).

    Model-1 of 2

    model 2 of 2

    Tuesday, September 20, 2011 8:03 AM
  • User-1712241964 posted

    here is a link to a page where the field displays the many-to-many info properly:

    http://ringgoldfootball.com/players/default.aspx
    (note the "WR", "DB", "OL", etc... values beneath players names)

    If a players name or image is clicked, it takes you to a player profile page displaying more info unique to that player(stats, etc).
    It is the single player view page on which I am seeming to be unable to display the same field.
    (note: game selection grid does not display for players for whom stats have not yet been entered by the coach.  that is intentional.)

     

    Tuesday, September 20, 2011 8:16 AM
  • User3866881 posted

    I am seeming to be unable to display the same field.

    Which field(s) do you want to show in the PlayerInfo.aspx? Do you mean something like "WB", or"OR"??

    If yes, tell me where you save them, what relationships do this have with tables?

    Thx again

    Tuesday, September 20, 2011 9:13 PM
  • User-236004499 posted

    Hi,

    I just have quick look on ur relationship diagram and datastructure. Very quick question by which fields do u make relationship between
    PlayerPositions and Rosters ???

    I thnik you should have a column "FK_PlayerPositionID" on "Rosters" Table and link with that column (I don't know what is use of Number column), but if u do in this way it will be manyTomany. 
    OR
    To make it drilldown field (link to show related positions) i think you probebly need to create another table "PlayerPosition_Mapping" where you will positions of players, then it will be oneToMany.

    Thnaks
    Pratik

     

    Tuesday, September 20, 2011 10:06 PM
  • User-1712241964 posted

    Here is the table in the db where the many-to-many records exist:
    playerpos

    Here is how the field appears within the auto-scaffolded pages of DD:
    scaffold

    Here is how the same field displays(as expected) on Default.aspx:
    ppage

    The problem is that when I add the same field to DetailsView2 on PlayerInfo.aspx, it will display the data just as wonderfully as it does on Default.aspx, but I instantly begin getting the above referenced script error, rendering the “Select” link within each row of GridView1 broken.

    -Gary

    Wednesday, September 21, 2011 11:19 AM
  • User-1712241964 posted

    found it!
    I had turned scaffolding off for 'PlayerPositions' because I wanted to display the values but not have them be used for navigation(not hyperlinked).
    changed:

    [MetadataType(typeof(PlayerPositionsMetadata))]
            [DisplayName("Player Positions")]
            [ScaffoldTable(false)]
            public partial class PlayerPositions

    to:

    [MetadataType(typeof(PlayerPositionsMetadata))]
            [DisplayName("Player Positions")]
            //[ScaffoldTable(false)]
            public partial class PlayerPositions

    I'll mark this post as the 'answer', as removing this attribute removes the 'breakage', but I'm still at a loss as to why it has the effect in this instance and will search for an alternate method by which to disable the navigation.
    Thanks again to all who gave this issue thought and chimed in!

    -Gary

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 22, 2011 11:06 AM