Link to home
Start Free TrialLog in
Avatar of sdh68
sdh68

asked on

reorderlist sort descending

Hello,

Recently I've been working on a football depth chart web application.  I've been making use of the ajaxcontroltoolkit's reorderlist control with a sqldatasource in order to handle the reordering of individual players by position, and it works well.  However, for the second half of my application I need to show the list in reverse (e.g. instead of showing 1,2,3 top to bottom I need to show 1,2,3 bottom to top).  I changed my sql statement to sort descending instead of ascending, and on the initial view the data appears as desired.  When I reorder the list the items appear to act as expected, but the reorderlist does not update the database properly.  The sort order database field (in this case called playerdepth) values climb with each successive reorder and also refuse to save in the correct order.  

So my question: is it possible to sort this list from bottom to top and successfullly reorder it through the use of the reorderlist control?  I can post some code if need be, but it's a pretty simple implementation.     Any help is greatly appreciated.
The data source, which renders correctly:

                        <asp:SqlDataSource ID="dsPos1" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:DataCon %>" 
                            SelectCommand="SELECT PlayerDepth, PlayerID, LastName, PositionAbbr, JerseyNumber, Height,Weight,DepthID, Speed, CAST(ISNULL(EntryYear, '-') AS nvarchar(4)) + '/' + CAST(ISNULL(DraftRound, '-') AS nvarchar(2)) AS DraftInfo FROM DepthChartPlayersTemp WHERE (CurrentClub = @CurrentClub) AND (PositionID = @Position) ORDER BY PlayerDepth desc" 

                  UpdateCommand="Update DepthChartPlayersTemp Set PlayerDepth = @PlayerDepth where DepthID = @DepthID">
                            <SelectParameters>
                                <asp:Parameter Name="CurrentClub" />
                                <asp:Parameter Name="Position" />
                            </SelectParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="PlayerDepth" />
                                <asp:Parameter Name="DepthID" />
                            </UpdateParameters>
                        </asp:SqlDataSource>


And the reorderlist: 

cc1:ReorderList ID="rePos1" runat="server" 
                            DataKeyField="DepthID" DataSourceID="dsPos1" PostBackOnReorder="False" 
                            SortOrderField="PlayerDepth" CssClass="reorderStyle" AllowReorder="True">
                            <ItemTemplate>
                                <table cellpadding="0" cellspacing="0" class="style1" 
                                    
                                    style="font-family: Calibri; border: 1px solid #000000; background-color: #FFFFFF; font-size: 8pt;" 
                                    >
                                    <tr>
                                        <td>
                                            <asp:Label ID="lblJersey" runat="server" Text='<%# Eval("JerseyNumber") %>' 
                                                Width="25%"></asp:Label>
                                        </td>
                                        <td colspan="3">
                                            <asp:Label ID="lblName" runat="server" Text='<%# Eval("LastName") %>' 
                                                Width="25%"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lblHeight" runat="server" Text='<%# Eval("Height") %>' 
                                                Width="25%"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblWeight" runat="server" Text='<%# Eval("Weight") %>' 
                                                Width="25%"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblSpeed" runat="server" Text='<%# Eval("Speed") %>' Width="25%"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lblDraft" runat="server" Text='<%# Eval("DraftInfo") %>' 
                                                Width="25%"></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </ItemTemplate>
                        </cc1:ReorderList>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial