Update reorderList with sqlDataSource

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
<connectionStrings>
    <add name="ConnectionString" connectionString
    ="Server=localhost;Database=School;Trusted_Connection=true"/>
   
  </connectionStrings>

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

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

 <asp:SqlDataSource ConnectionString
 ='<%$ ConnectionStrings:ConnectionString %>' ID="SqlDataSource1"
 runat="server"
       SelectCommand="SELECT * FROM Categories ORDER BY [Order] ASC"
        UpdateCommand="UPDATE Categories SET [Order] =
        @Order WHERE CategoryID = @original_CategoryID"
         OldValuesParameterFormatString = "original_{0}">      
     
      <UpdateParameters>
      <asp:Parameter Name="Order" Type="Int32" />
      <asp:Parameter Name="original_CategoryID" Type="Int32" />
      </UpdateParameters>
     
      </asp:SqlDataSource>  
wahoooAsked:
Who is Participating?
 
Tommie Nathaniel Carter, Jr., MBAFounderCommented:
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

http://aspnet.4guysfromrolla.com/articles/040502-1.aspx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.