R – Subsonic-Paging-Order problem

custompagingsortingsubsonic

I have a datagrid where I am using the custom paging option (ref: http://subsonicproject.com/querying/webcast-using-paging/) in the Subsonic framework.

I also have a dropdown that filters the data by State. This is added to the query through the addwhere call.

the data is ordered by state ASC and then city ASC.

the data seems to be ordered fine when no state is selected and thus no addwhere is added to the clause. But if you select a state that has enough records to cause pagination to kick in, then some records are displayed out of order. I have also noticed that it always seems to be the last few records on the current page are displayed somewhere in the middle of the grid.

snippet of code to loadgrid:

    Dim qry As New SubSonic.Query( {myTableSchema} )
    If ddlStates.SelectedValue.Trim.ToLower <> "all states" Then
        qry.AddWhere("state", ddlStates.SelectedValue.Trim)
    End If
    qry.ORDER_BY("state", "ASC").ORDER_BY("city", "ASC")
    qry.PageSize = ddlDisplay.SelectedValue
    qry.PageIndex = pageNumber
    gvOrganizers.DataSource = qry.ExecuteDataSet
    gvOrganizers.DataBind()

The problem doesn't seem to appear when a state is selected and there is only 1 page of data. Default ddlDisplay setting is 100 records per page but the error appears even if 50 or 25 is chosen.

Using Subsonic 2.1.0.0

Best Answer

Use qry.OrderAsc(New String(){"state asc, city asc"})

Related Topic