我将一个由SQLDataSource绑定的AjaxControlToolkit ReorderList连接到具有以下模式的表:
OrgID MilestoneID Name Priority
优先级字段作为其SortOrderField附加到ReorderList。 OrgID特定于每个登录的用户。想法是每个组织都有一个不同的里程碑列表。
我没有使用任何代码。在EditItemTemplate中,我有两个用于更新和取消的ImageButtons。当我单击“更新”时,里程碑的名称会更新,但优先级将设置为null。我无法弄清楚为什么会这样。
以下是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>
任何想法为什么名称会更新但优先权不会?
答案 0 :(得分:2)
我没有使用ReoRder lister控件,但是你会认为你还需要绑定到优先级才能将它发送到你的DataSource吗?例如
<asp:TextBox ID="TextBoxPriorty" runat="server" Text='<%# Bind("Priority") %>'></asp:TextBox>