locked
GridView Sorts differently on different servers RRS feed

  • Question

  • User1414979851 posted

    Can someone point me in the right direction to figure out what is different on two servers that may cause the following problem:

    An identical ASP.NET webpage using a Gridview is on two different servers. The gridview is configured to allow sorts


    On one website/server (server 1) the gridview behaves as expected:
    Page loads and the gridview is sorted the same as the data source.
    Click the sort link on any other column first time, that column is sorted ascending (as expected)
    Click on same column second time, the column is sorted descending
    Click on a different column first time, that column is sorted ascending
    ... and so on

    On the other server (server 2) the gridview seems to sort one click behind.
    Page loads and the gridview is sorted the same as the data source.
    Click the sort link on any other column (E.G. 2nd column) first time. no resort occurs (but, the page seems to post back)
    Click on the same column a second time, now it is sorted ascending in the post back.
    Click on any OTHER column (3rd column) , the previous column (2nd column) clicked now sorts descending
    (I.E. click 3rd column sort link, the 2nd column sorts descending but the 3rd column does not sort)

    Another way to describe this is that the sorting of columns seems to be one click behind on server 2.

    The page has an update button that just re-binds the gridview. When the update button is clicked:
    On server 1 the gridview is updated and remains sorted as it was after the last sort - as expected.
    On server 2 the gridview is updated and also gets sorted according to the last column sort that was expected but did not take place.

    Both servers have the identical page (Jstat.aspx and Jstat.aspx.cs are exactly the same)
    As far as I can tell, IIS on the servers are configured almost the same (differences listed below).
    Both servers use the same version of ASP.NET (4.0).
    The server roles and features that seem applicable are the same (differences listed below)
    The data source is a MS Access table. The tables have identical design but different data.

    More information: I have a copy of Visual Studio on each server.
    If I run the page (with or without debugging) using visual studio:
    On server 1 the page behaves as expected.
    On server 2, the page behaves the same running under VS as it does over the internet to the server. I.E. the gridview sorts seem to be one click behind.

    If I follow the code on server 2 using debug, the select command (saved in Session["SelComm"]) is configured for the proper sort just before the gridview data bind and no errors occur but after the code runs - it seems the actual post to the webserver is not done. I.E. the select command text is correct just before the gridview bind but the webpage is not updated according to the select command ORDER BY ... .

    The situation seems to be server related - although I have yet to find a difference that would create this situation.


    -----------------------------
    gridview aspx page applicable source in Jstat.aspx:
    -----------------------------
    ...
    <body>
    <form id="form1" runat="server">
    <asp:Button ID="BtnUpdate" runat="server" Text="Update" OnClick="BtnUpdate_Click" />
    <div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" AllowSorting="True" OnSorting="GridView1_Sorting">
    <Columns>
    <asp:BoundField DataField="NCAT" HeaderText="NCAT" SortExpression="NCAT" />
    <asp:BoundField DataField="EXN" HeaderText="EXN" SortExpression="EXN" />
    <asp:BoundField DataField="JUN" HeaderText="JUN" SortExpression="JUN" />
    <asp:BoundField DataField="NTR" HeaderText="NTJ" SortExpression="NTR" />
    <asp:BoundField DataField="AppJun" HeaderText="AppJun" SortExpression="AppJun" />
    <asp:BoundField DataField="BSeq" HeaderText="Status" SortExpression="BSeq" />
    <asp:BoundField DataField="FNAME" HeaderText="FNAME" SortExpression="FNAME" />
    <asp:BoundField DataField="LNAME" HeaderText="LNAME" SortExpression="LNAME" />
    </Columns>
    </asp:GridView>
    </div>
    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/SciFairData.mdb"
    SelectCommand="SELECT ExhibitJudges.JUN, ExhibitJudges.EXN, Persons.FNAME, Persons.LNAME, Categories.NCAT,
    NTR, BSeq, ExhibitJudges.AppStat, ExhibitJudges.AppJun FROM ((Categories RIGHT JOIN ExhibitData ON Categories.NCAT = ExhibitData.NCAT)
    RIGHT JOIN ExhibitJudges ON ExhibitData.EXN = ExhibitJudges.EXN)
    LEFT JOIN (Persons RIGHT JOIN Judges ON Persons.PID = Judges.PID) ON ExhibitJudges.JUN = Judges.JUN; " >

    </asp:AccessDataSource>

    </form>
    </body>
    ...
    ----------------------------
    The page c# applicable code in Jstat.aspx.cs:
    --------------------------
    ...
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!Page.IsPostBack) /// NOT USED
    {
    AccessDataSource1.SelectCommand = "SELECT ExhibitJudges.JUN, ExhibitJudges.EXN, Persons.FNAME, Persons.LNAME, Categories.NCAT, " +
    "NTR, BSeq, ExhibitJudges.AppStat, ExhibitJudges.AppJun FROM ((Categories RIGHT JOIN ExhibitData ON Categories.NCAT = ExhibitData.NCAT) " +
    "RIGHT JOIN ExhibitJudges ON ExhibitData.EXN = ExhibitJudges.EXN) " +
    "LEFT JOIN (Persons RIGHT JOIN Judges ON Persons.PID = Judges.PID) ON ExhibitJudges.JUN = Judges.JUN ";
    Session["SelComm"] = AccessDataSource1.SelectCommand;
    BtnUpdate_Click(null, null); // bind the gridview
    }
    // do nothing if postback
    }
    protected void BtnUpdate_Click(object sender, EventArgs e)
    {
    AccessDataSource1.SelectCommand = Session["SelComm"].ToString();
    GridView1.DataBind();
    }
    protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
    {
    BtnUpdate_Click(null, null);
    }
    ...

    Notice the aspx AccessDataSource Select command in this example is the same as in the Page_Load. In my actual situation, I will be changing the Select command in the Page_Load given different users log in. This code is the simple version that shows the problem.


    -----------------------------
    *** Server Differences ****
    ------------------------------

    Both servers are version 6.1 (7601 SP1)
    Server differences I have found:
    Server 1 is 'Standard'; Server 2 is 'Data Center'
    Server 1 has CGI installed and running; Server 2 does not
    Server 1 has HTTP Redirection installed; Server 2 does not
    Server 1 does not have FTP role installed; Server 2 does
    Server 1 has DigestAuthentication Module; Server 2 does not
    Server 1 has two websites (the ASP.NET site with this page and a PHP Drupal website); Server 2 has only the ASP.NET site with this page.

    IIS differences I have found:
    Server 1 IIS does NOT have ISAPI dll version 2.0; Server 2 does
    Server 1 IIS has Module CGIModule; Server 2 does not
    Server 1 IIS has FastCGIModuel; Server 2 does not
    Server 1 IIS has HTTP Redirection Module (not enabled); Server 2 does not
    Server 1 IIS has HTTP URL Rewrite (icon ); Server 2 does not
    Server 1 has DigestAuthenticationModule; Server 2 does not
    Server 1 has PHP Manager (icon); Server 2 does not

    I do not know if any of the above would cause the symptoms but I have not installed the missing roles on Server 2 (IT must do that)

    Thursday, November 3, 2016 8:07 PM

Answers

  • User1414979851 posted

    Found the problem.  This is a BUG in .NET Framework 4.6

    I installed .Net Framework 4.6.1 on server 2 and now both servers sort the gridview as expected.    Problem solved!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 5, 2016 5:03 PM

All replies

  • User-1716253493 posted

    try check columns datatype

    Friday, November 4, 2016 1:03 AM
  • User1414979851 posted

    Data types in the source are exactly the same.  Only the data (either integer or strings ) in the source MS Access table are different.  However, I will copy the data source files from server 1 to server 2 and see if that makes a difference. (They were created by different versions of MS Office).  Anyone else have any suggestions?  

    Friday, November 4, 2016 2:35 PM
  • User1414979851 posted

    I just copied the data source Access database from Server 1 to server 2. That eliminates any differences in the data source. The problem still exists even when the data on both servers are the same.   SciFairData.mbd are the same file, same tables, same data.   Oh me o my what is going on? 

    Same data source exactly;  Same ASP.NET page source exactly;  Same ASP.NET version on both servers as far as I can tell;  Only differences I see are the ones I have listed.

    What difference could cause this - What about this?

    Server 1 is dedicated hardware in a data center,  Server 2 is a virtual server in a data center. (But both run the same version of Windows Server 2008)

    Friday, November 4, 2016 3:09 PM
  • User1414979851 posted

    I may have found the issue.  There is another difference

    Server 1 has .Net Framework version 4.5.2     Server 2 has .Net Framework version 4.6

    Another site's forum has a topic very similar related to Paging on gridview being one click behind.  That issue is a bug in version 4.6 fixed in version 4.6.1

    Saturday, November 5, 2016 3:32 PM
  • User1414979851 posted

    Found the problem.  This is a BUG in .NET Framework 4.6

    I installed .Net Framework 4.6.1 on server 2 and now both servers sort the gridview as expected.    Problem solved!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 5, 2016 5:03 PM