?
Solved

reorderlist sort descending

Posted on 2009-12-29
1
Medium Priority
?
573 Views
Last Modified: 2013-11-08
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

0
Comment
Question by:sdh68
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 26146426
I don't see a way.  If you have the source code for the AJAX control toolkit 3.0, you can see that there is an internal method (ReorderList.DoReorderInternal), that performs the sorting.  It looks like it only handles ascending sorts.

private bool DoReorderInternal(IEnumerable dataSource, int oldIndex, int newIndex, DataSourceView dsv)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question