views:

867

answers:

1

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" />&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>

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

+2  A: 

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>
Dan Diplo
This works. WTH? This seems really hokey, but it works, so +1!
Matthew Jones