ASP.NET ReorderList - 更新失败

发布于 2024-07-29 14:04:15 字数 4176 浏览 1 评论 0原文

我有一个 AjaxControlToolkit ReorderList,由 SQLDataSource 绑定到具有以下架构的表:

OrgID   MilestoneID   Name   Priority

Priority 字段作为其 SortOrderField 附加到 ReorderList。 OrgID 特定于每个登录的用户。其想法是每个组织都有不同的里程碑列表。

我没有使用后面的代码。 在 EditItemTemplate 中,我有两个用于更新和取消的图像按钮。 当我单击“更新”时,里程碑的名称会更新,但优先级会设置为空。 我不明白为什么会发生这种情况。

以下是 ReorderList 及其 SQLDataSource 的源代码:

<cc1:ReorderList ID="ReorderList1" runat="server" AllowReorder="True" 
            CssClass="reorderStyle" DataKeyField="MilestoneID" 
            DataSourceID="SqlDataSource2"
            OnItemDataBound="ReorderList1_ItemDataBound" 
            OnItemReorder="ReorderList1_ItemReorder" PostBackOnReorder="True" 
                    SortOrderField="Priority" Width="400px">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButton2" runat="server" CommandName="Edit" 
                            ImageUrl="~/Images/edit.gif" />
                        <asp:Label ID="Label1" runat="server"
                    Text='<%# Eval("Name") %>' 
                    ForeColor="Navy" Font-Names="Arial" />
                    </ItemTemplate>
                    <DragHandleTemplate>
                        <img src="../Images/GrabIcon.GIF" style="cursor: move" />&nbsp;
                    </DragHandleTemplate>
                    <InsertItemTemplate>
                    </InsertItemTemplate>
                    <EmptyListTemplate>
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Italic="False" ForeColor="Red"
                    Text="There are no Associated Milestones currently in the database"></asp:Label>
                    </EmptyListTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                        <asp:ImageButton ID="ImageButton1" runat="server" CommandName="Update" 
                            ImageUrl="~/Images/save.gif" />
                        &nbsp;
                        <asp:ImageButton ID="ImageButton3" runat="server" CommandName="Cancel" 
                            ImageUrl="~/Images/cancel.gif" />
                    </EditItemTemplate>
                </cc1:ReorderList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" 
                    DeleteCommand="DELETE FROM [Milestones] WHERE [MilestoneID] = @MilestoneID" 
                    InsertCommand="INSERT INTO [Milestones] ([OrgID], [Name], [Priority]) VALUES (@OrgID, @Name, @Priority)" 
                    SelectCommand="SELECT MilestoneID, [Name], [Priority] FROM [Milestones] WHERE OrgID = @OrgID ORDER BY [Priority]" 

                    UpdateCommand="UPDATE [Milestones] SET [Name] = @Name, Priority = @Priority WHERE [MilestoneID] = @MilestoneID">
                    <SelectParameters>
                        <asp:ProfileParameter Name="OrgID" PropertyName="OrgID" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter DbType="Guid" Name="MilestoneID" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Priority" Type="Int32" />
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter DbType="Guid" Name="MilestoneID" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ProfileParameter Name="OrgID" PropertyName="OrgID" />
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Priority" Type="Int32" />
                    </InsertParameters>
                </asp:SqlDataSource>

知道为什么名称会更新但优先级不会更新吗?

I have an AjaxControlToolkit ReorderList bound by a SQLDataSource to a table with the following schema:

OrgID   MilestoneID   Name   Priority

The Priority field is attached to the ReorderList as its SortOrderField. OrgID is specific to each user that logs in. The idea is that there is a different list of Milestones for each Org.

I am using no code behind. In the EditItemTemplate i have two ImageButtons for Update and Cancel. When I click Update the Name of the milestone gets updated but the Priority gets set to null. I cannot figure out why this is happening.

Here is the source code for the ReorderList and its SQLDataSource:

<cc1:ReorderList ID="ReorderList1" runat="server" AllowReorder="True" 
            CssClass="reorderStyle" DataKeyField="MilestoneID" 
            DataSourceID="SqlDataSource2"
            OnItemDataBound="ReorderList1_ItemDataBound" 
            OnItemReorder="ReorderList1_ItemReorder" PostBackOnReorder="True" 
                    SortOrderField="Priority" Width="400px">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButton2" runat="server" CommandName="Edit" 
                            ImageUrl="~/Images/edit.gif" />
                        <asp:Label ID="Label1" runat="server"
                    Text='<%# Eval("Name") %>' 
                    ForeColor="Navy" Font-Names="Arial" />
                    </ItemTemplate>
                    <DragHandleTemplate>
                        <img src="../Images/GrabIcon.GIF" style="cursor: move" /> 
                    </DragHandleTemplate>
                    <InsertItemTemplate>
                    </InsertItemTemplate>
                    <EmptyListTemplate>
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Font-Italic="False" ForeColor="Red"
                    Text="There are no Associated Milestones currently in the database"></asp:Label>
                    </EmptyListTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
                        <asp:ImageButton ID="ImageButton1" runat="server" CommandName="Update" 
                            ImageUrl="~/Images/save.gif" />
                         
                        <asp:ImageButton ID="ImageButton3" runat="server" CommandName="Cancel" 
                            ImageUrl="~/Images/cancel.gif" />
                    </EditItemTemplate>
                </cc1:ReorderList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:MyConnectionString %>" 
                    DeleteCommand="DELETE FROM [Milestones] WHERE [MilestoneID] = @MilestoneID" 
                    InsertCommand="INSERT INTO [Milestones] ([OrgID], [Name], [Priority]) VALUES (@OrgID, @Name, @Priority)" 
                    SelectCommand="SELECT MilestoneID, [Name], [Priority] FROM [Milestones] WHERE OrgID = @OrgID ORDER BY [Priority]" 

                    UpdateCommand="UPDATE [Milestones] SET [Name] = @Name, Priority = @Priority WHERE [MilestoneID] = @MilestoneID">
                    <SelectParameters>
                        <asp:ProfileParameter Name="OrgID" PropertyName="OrgID" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter DbType="Guid" Name="MilestoneID" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Priority" Type="Int32" />
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter DbType="Guid" Name="MilestoneID" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:ProfileParameter Name="OrgID" PropertyName="OrgID" />
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Priority" Type="Int32" />
                    </InsertParameters>
                </asp:SqlDataSource>

Any ideas why the Name would get updated but the Priority would not?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一指流沙 2024-08-05 14:04:15

我没有使用 ReoRder lister 控件,但我认为您仍然需要绑定到优先级才能将其发送到您的数据源? 例如。

<asp:TextBox ID="TextBoxPriorty" runat="server" Text='<%# Bind("Priority") %>'></asp:TextBox>

I haven't used the ReoRder lister control, but would have thought you still need to Bind to Priority to have it sent to your DataSource? Eg.

<asp:TextBox ID="TextBoxPriorty" runat="server" Text='<%# Bind("Priority") %>'></asp:TextBox>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文