Search code examples
asp.netentitydatasource

Filtering data using EntityDataSource (dropdownlist)


I have a drop down list that is using entitydatasource, the user select a value form drop down list and the Grid View change based on the Order Status (Drowpdownlist). Below is the grid view DataSource. It works but when I go to page 4 for example and then shows a different value from dropdown list the grid view disappears. Please help.

    <asp:EntityDataSource ID="GridViewEDS" runat="server" ConnectionString="name=ServiceEntities" DefaultContainerName="ServiceEntities"
         EnableFlattening="False" EntitySetName="Orders" Where="it.[OrderStatus] == @OrderStatus">
       <WhereParameters>
            <asp:ControlParameter Name="OrderStatus" ControlID="OrderStatusDropDownList" DbType="String" DefaultValue="Null"/>
       </WhereParameters>

Solution

  • After clearing some things up in the comments, a solution to this would be to set the current page on the GridView back to the first page when a new selection is made in the DropDownList. One reason for this would be because a secondary result set doesn't contain enough records to fill more than one page, therefore displaying nothing.

    gridView.PageIndex = 0;