ListBox Re-Order Not updating database

2 posts, 0 answers
  1. Jim
    Jim avatar
    15 posts
    Member since:
    Oct 2012

    Posted 06 Mar 2014 Link to this post

    I am using radlistbox to change a display order field.  SqlDataSource fires updated event for appropriate items but the displayorder integer does not get changed.  I'm at a loss as to how to troubleshoot this issue.   code below.

    <telerik:RadListBox runat="server" ID="rlbxFields" DataSourceID="sqlFields" AllowDelete="True" AllowReorder="True" DataKeyField="ID" DataSortField="DisplayOrder" DataTextField="LabelText" DataValueField="ID" AllowAutomaticUpdates="true" AutoPostBackOnReorder="true" AutoPostBackOnDelete="true" EnableDragAndDrop="true"></telerik:RadListBox>
    <asp:SqlDataSource ID="sqlFields" runat="server" ConnectionString="<%$ ConnectionStrings:zPortalConnectionString %>" DeleteCommand="DeleteFormField" DeleteCommandType="StoredProcedure" InsertCommand="UpsertFormField" InsertCommandType="StoredProcedure" SelectCommand="GetFormFields" SelectCommandType="StoredProcedure" UpdateCommand="UpsertFormField" UpdateCommandType="StoredProcedure">
    <DeleteParameters>
    <asp:Parameter Name="ID" DbType="Guid" />
    </DeleteParameters>
    <InsertParameters>
    <asp:Parameter Name="FormID" DbType="Guid" />
    <asp:Parameter Name="ID" DbType="Guid" />
    <asp:Parameter Name="LabelText" Type="String" />
    <asp:Parameter Name="Type" Type="String" />
    <asp:Parameter Name="DisplayOrder" Type="Int32" />
    <asp:Parameter Name="Required" Type="Boolean" />
    <asp:Parameter Direction="InputOutput" Name="ID_OUT" DbType="Guid" />
    </InsertParameters>
    <SelectParameters>
    <asp:Parameter Name="FormID" DbType="Guid" />
    </SelectParameters>
    <UpdateParameters>
    <asp:Parameter Name="FormID" DbType="Guid" />
    <asp:Parameter Name="ID" DbType="Guid" />
    <asp:Parameter Name="LabelText" Type="String" />
    <asp:Parameter Name="Type" Type="String" />
    <asp:Parameter Name="DisplayOrder" Type="Int32" />
    <asp:Parameter Name="Required" Type="Boolean" />
    <asp:Parameter Direction="InputOutput" Name="ID_OUT" DbType="Guid" />
    </UpdateParameters>
    </asp:SqlDataSource>
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 10 Mar 2014 Link to this post

    Hi Jim,

    The definition of the ListBox looks good. Check if the Select and the Update commands are working properly. After you reorder the items look at the DB and verify that "DisplayOrder" field has been updated. If it is the the problem is with the Select command. Don't forget to add "ORDER BY" clause, so you can get the updated data:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" 
                SelectCommand="SELECT * FROM [Countries] ORDER BY [SortOrder]"


    Regards,
    Hristo Valyavicharski
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top