Update reorderList with sqlDataSource

Posted on 2007-08-03
Last Modified: 2012-08-13
Is it possible to update the reorderList (and the database) with the UpdateCommand in sqlDataSource?

I tried something I found on the internet:
"UPDATE Categories SET [Order] = @Order WHERE CategoryID = @original_CategoryID"

(Link to website is only cached by Google, and the code is therefore inserted at the bottom of this text.)

This seems wrong (and doesn't work) since it only takes the "Order" parameter from the item you are moving and setting it to the same value it was before moving it.

Do you know some way to use sqlDataSource to update the reorderList and database's order?

Example code:
// Connection String
    <add name="ConnectionString" connectionString

 <cc1:ReorderList CssClass="ReOrderControlStyle"
 OnItemReorder="ReOrderItemEvent" SortOrderField="Order" AllowReorder="true"

             ItemInsertLocation="Beginning" DragHandleAlignment="left"
             DataSourceID="SqlDataSource1" ID="ReorderList1" runat="server">
            <asp:Label ID="lblCategoryName" runat="server"
            Text='<%# Eval("CategoryName") %>' />

 <asp:SqlDataSource ConnectionString
 ='<%$ ConnectionStrings:ConnectionString %>' ID="SqlDataSource1"
       SelectCommand="SELECT * FROM Categories ORDER BY [Order] ASC"
        UpdateCommand="UPDATE Categories SET [Order] =
        @Order WHERE CategoryID = @original_CategoryID"
         OldValuesParameterFormatString = "original_{0}">      
      <asp:Parameter Name="Order" Type="Int32" />
      <asp:Parameter Name="original_CategoryID" Type="Int32" />
Question by:wahooo
    1 Comment
    LVL 4

    Accepted Solution

    The correct way to do an upgrade would be with the Datagrid Update Command or an update command from whatever you are binding the data to.

    Please (re-) read the 4guys article it will help

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now