Search code examples
asp.netreportviewerlinqdatasource

Row Order error when populating Report Viewer control bound to LinqDataSource


I have an Availability Report Viewer control bound to a LinqDataSource:

<MyReport:ReportViewer ID="rvAvailabilty" runat="server" >
    <LocalReport>
        <DataSources>
            <MyReport:ReportDataSource DataSourceId="ldsAvailabiltyRows" Name="DataSetAvailabilty" />
        </DataSources>
    </LocalReport>
</MyReport:ReportViewer>


<asp:LinqDataSource ID="ldsAvailabiltyRows" runat="server" ContextTypeName="MyApp.MyDataContext" EntityTypeName="MyApp.AvailabiltyRow" OnSelecting="ldsAvailabiltyRows_Selecting" >
</asp:LinqDataSource> 

In the code behind, I am specifying a repository call to return a ordered (alphabetic) set of rows. The order is correct from the repository.

public void ldsAvailabiltyRows_Selecting(object sender, LinqDataSourceSelectEventArgs e)
{
    e.Result = repo.GetReportAvailabiltyRows(); // this repository call returns the correctly ordered data set
}

However, when the report is generated, the order of the dataset is not working on the report. How can I enforce correct top to bottom order on my report?


Solution

  • I discovered my own answer : The report's RDLC had a group defined at the row level of it's tablix. Within each group there is a default Sort By column created, and this setting was overriding whatever order my LinqDataSource was specifying.