locked
passing a value from ListView to EntityDataSource RRS feed

  • Question

  • User-2020164760 posted

    Hi,

    I have this code, and I need the "it.MembershipOption.Id" value in the "where" clause to be the <%# Eval("Id") %> from ListViewEventsOuter. I tried to add the Eval in the "where" clause but it throws an error.

    How is this done?

    Thanks

    <asp:ListView ID="ListViewEventsOuter" runat="server">
       
    <ItemTemplate>
            <a name='
    <%# Eval("Id") %>'></a>
           
    <h3>Events for <%# Eval("Text")%> members</h3>

           
    <asp:EntityDataSource ID="EntityDataSource1" runat="server"
           
    ConnectionString="name=LighthouseEntities" Include="EventType, MembershipOption"
           
    DefaultContainerName="LighthouseEntities" EntitySetName="Events"
           
    EntityTypeFilter="" Select="" Where='it.Active == True && it.MembershipOption.Id == [THIS VALUE TO COME FROM THE PREVIOUS ID IN LISTVIEW]'>
           
    </asp:EntityDataSource>

           
    <asp:ListView ID="ListViewEventsInner" runat="server">

                  ETC....

    Monday, January 24, 2011 10:04 AM

Answers

  • User626880745 posted

    Use a HiddenField as a ControlParameter for the nested EntityDataSource (EDS). 


    <h3> Events......</h3>

    <asp:HiddenField ID="HiddenField1" runat="server" Value='<%# Eval("ID") %>' />

    <asp:EntityDataSource ID="EntityDataSource1"   .......
    Where="it.Active == True && it.MembershipIotion.ID == @ID">
       <WhereParameters>
           <asp:ControlParameter ControlID="HiddenField1" PropertyName="Value" Name="ID" />
       </WhereParameters>
    <asp:EntityDataSource>
    <asp:ListView ID="ListViewEventsInner"................./>


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 24, 2011 10:55 AM