ASP.NET ReorderList - 更新失败
我有一个 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" />
</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>
知道为什么名称会更新但优先级不会更新吗?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有使用 ReoRder lister 控件,但我认为您仍然需要绑定到优先级才能将其发送到您的数据源? 例如。
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.