Answered by:
Learning ReOrder Lists AjaxToolKit 4.0

Question
-
User402920586 posted
ok I am stumpted I have searched through and read coding for this and I don't understand what I'm missing. The list posts back but will not update the MSSQL database. It's bound to be something simple. I can not find it, through. Any help or a point in the right direction would be much appreciated.
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ReorderList runat="server" AllowReorder="True" DataSourceID="SqlDataSource1" DataKeyField="ID" SortOrderField="Priority" Width="100%"> <ItemTemplate> <div> <asp:Table ID="Table1" runat="server"> <asp:TableRow> <asp:TableCell RowSpan="2" Width="15px"> <asp:Label ID="Priority" runat="server" Text='<%#Eval("Priority") %>' /> </asp:TableCell> <asp:TableCell Width="300px"> <asp:Label ID="lblid" runat="server" Value='<%#Eval("ID") %>' /> <asp:Label ID="Label4" runat="server" Text='<%#Eval("project") %>' /><br /> <asp:Label ID="Label5" runat="server" Text='<%#Eval("Assoc") %>' /><br /> <asp:Label ID="Label6" runat="server" Text='<%#Eval("Assoc_Email") %>' /> </asp:TableCell> <asp:TableCell> <asp:Label ID="Label7" runat="server" Text='<%#Eval("Hours") %>' /> Hour(s)<br /> <asp:Label ID="Label8" runat="server" Text='<%#Eval("Status") %>' /> </asp:TableCell> </asp:TableRow> </asp:Table> </div> </ItemTemplate> <DragHandleTemplate> <div> <img src="myi/fifa.png" alt="reorder" height="55" /></div> </DragHandleTemplate> <ReorderTemplate> <div> </div> </ReorderTemplate> <EditItemTemplate> <div> <asp:Table ID="Table1" runat="server"> <asp:TableRow> <asp:TableCell RowSpan="2" Width="15px"> <asp:TextBox ID="txtPriority" runat="server" Text='<%#Bind("Priority") %>' /> </asp:TableCell> <asp:TableCell Width="300px"> <asp:TextBox ID="txtID" runat="server" Text='<%#Bind("ID") %>' /> <asp:TextBox ID="txtproject" runat="server" Text='<%#Bind("project") %>' /><br /> <asp:TextBox ID="txtAssoc" runat="server" Text='<%#Bind("Assoc") %>' /><br /> <asp:TextBox ID="txtAssoc_Email" runat="server" Text='<%#Bind("Assoc_Email") %>' /> </asp:TableCell> <asp:TableCell> <asp:TextBox ID="txtHours" runat="server" Text='<%#Bind("Hours") %>' /> Hour(s)<br /> <asp:TextBox ID="txtStatus" runat="server" Text='<%#Bind("Status") %>' /> </asp:TableCell> </asp:TableRow> </asp:Table> </div> </EditItemTemplate> <EmptyListTemplate> <div> No items exist. </div> </EmptyListTemplate> </asp:ReorderList> </ContentTemplate> </asp:UpdatePanel> </asp:TableCell> </asp:TableRow> </asp:Table> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBconn %>" SelectCommand="SELECT [ID], [Priority], [project], [Hours], [Assoc], [Assoc_Email], [Status] FROM [Scheduling] ORDER BY [Priority]" UpdateCommand="UPDATE [Scheduling] SET [Priority] = @Priority WHERE [ID] = @ID"> <UpdateParameters> <asp:Parameter Name="Priority" Type="Int64" /> <asp:Parameter Name="ID" Type="Int64" /> </UpdateParameters> </asp:SqlDataSource>
Wednesday, February 26, 2014 12:39 PM
Answers
-
User-417640953 posted
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DBconn %>" SelectCommand="SELECT [ID], [Priority], [project], [Hours], [Assoc], [Assoc_Email], [Status] FROM [Scheduling] ORDER BY [Priority]" UpdateCommand="UPDATE [Scheduling] SET [Priority] = @Priority WHERE [ID] = @ID"> <UpdateParameters> <asp:Parameter Name="Priority" Type="Int64" /> <asp:Parameter Name="ID" Type="Int64" /> </UpdateParameters> </asp:SqlDataSource>
Hello,
Thank you post the issue to asp.net forum.
Based on above code I quoted, you want to update the record using the SqlDataSource UpdateCommand
"UPDATE [Scheduling] SET [Priority] = @Priority WHERE [ID] = @ID". And you also set the UpdateParameters of SqlDataSource.
<UpdateParameters> <asp:Parameter Name="Priority" Type="Int64" /> <asp:Parameter Name="ID" Type="Int64" /> </UpdateParameters>
However, I have not see you assigned values to the two parameters "Priority" and "ID". Please set their value when postback.
For how to set values to Parameters of SqlDataSource, you can refer to below example.
http://msdn.microsoft.com/en-us/library/z72eefad.aspx
If I misunderstand your issue, please feel free to back. Thanks.
Best Regards!
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 27, 2014 9:50 PM