AjaxControlToolkit - ReorderList - 不执行Update语句

时间:2012-01-25 03:37:58

标签: asp.net vb.net sql-server-2008 tsql ajaxcontroltoolkit

似乎很多人都遇到了这个控制工具包的问题。我已经在互联网上寻找了几天的答案,但却找不到答案。我到目前为止看到的最佳解决方案是“编写自己的重新排序程序”,我不想这样做。

<asp:ScriptManager ID="smgrJobBidding" runat="server">
    </asp:ScriptManager>
<asp:UpdatePanel ID="uPanelReorderList" runat="server" 
    EnableViewState="False" ViewStateMode="Disabled">
    <ContentTemplate>
<ajaxToolkit:ReorderList ID="rlBiddingJobs" runat="server" AllowReorder="True" 
    DataKeyField="BidID" 
    DataSourceID="sqlDStblJobBids" 
    PostBackOnReorder="True" 
    SortOrderField="Preference" 
    DragHandleAlignment="Left"
    ClientIDMode="AutoID" 
    EnableViewState="False">
    <DragHandleTemplate>
       <div style="float:left;" class="DragHandleClass">
       </div>
    </DragHandleTemplate>
    <ItemTemplate>
        <asp:Button ID="btnDeleteSignup" runat="server" CommandName="Delete" 
        style="float:right;" Text="Delete" Width="75" Font-Size="Small" Height="20px" />
        <asp:Label ID="lblPostingID" runat="server" Text='<%# Eval("PostingID") %>'></asp:Label>
    </ItemTemplate>
</ajaxToolkit:ReorderList>
    </ContentTemplate>
</asp:UpdatePanel>

由于表格的规范化布局,SQL数据源对象有点笨重。

<asp:SqlDataSource ID="sqlDStblJobBids" runat="server" 
    ConnectionString="<%$ ConnectionStrings:JobsDB %>" 
    SelectCommand="SELECT dbo.tblJobBids.BidID, dbo.tblJobBids.PostingID, dbo.tblJobBids.EUID, dbo.tblJobBids.Preference, dbo.tblJobPostings.Shift, dbo.tblJobPostings.Needs, 
                  dbo.tblJobPostings.PostedDate, dbo.tblJobPostings.ClosingDate, dbo.tblDepartments.Department, dbo.tblJobs.JobName
FROM dbo.tblJobBids INNER JOIN
                  dbo.tblJobPostings ON dbo.tblJobBids.PostingID = dbo.tblJobPostings.PostingID     INNER JOIN
                  dbo.tblJobs ON dbo.tblJobPostings.JobID = dbo.tblJobs.JobID INNER JOIN
                  dbo.tblDepartments ON dbo.tblJobPostings.DepartmentID = dbo.tblDepartments.DeptID
WHERE tblJobPostings.ClosingDate &gt;= (SELECT GETDATE()) AND tblJobPostings.PostingID 
IN (SELECT tblJobBids.PostingID FROM  tblJobBids WHERE tblJobBids.EUID = @EUID)
ORDER BY tblJobBids.Preference Asc;"
    DeleteCommand="DELETE FROM tblJobBids WHERE tblJobBids.BidID = @BidID;" 
    UpdateCommand="UPDATE dbo.tblJobBids SET tblJobs.Preference = @Preference WHERE tblJobs.BidID = @BidID;" >
    <DeleteParameters>
        <asp:Parameter Name="BidID" />
    </DeleteParameters>
    <SelectParameters>
        <asp:SessionParameter Name="EUID" SessionField="sEUID" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="Preference" Type="Byte"/>
        <asp:Parameter Name="BidID" Type="Int32"/>
    </UpdateParameters>
</asp:SqlDataSource>

选择语句很好,我可以拖动所有我想要的项目,但是他们“橡皮筋”回到他们在拖动之前所处的位置。这就像更新语句不会在回发时触发。

我添加了一些故障排除代码来计算更新面板中的异步回发,它肯定会回发。数据库中的数据(SQL Server 2008 R2 Express)似乎没有更改。它可能会改变然后再改变......我正在看日志看。

看到任何明显错误的东西?

1 个答案:

答案 0 :(得分:0)

原来我很笨,我在SQL Server 2008中将SortOrderField的数据类型设置为“tinyint”。我将它从那个更改为“int”并且它现在正在工作。我最初创建它是“tinyint”因为偏好通常只会在一些小的范围内,比如1-10。无论如何,它现在正在发挥作用。

相关问题