Hi,
I try to use to Reorlist Conrol from the AJAX toolkit. Everything seems fine but when I drag and drop an item to change its order I have a javascript popup with the message "Unable to reorder. Reorder failed"
Here is the code of my page:
<
form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div class="demoheading">ReorderList Demonstration</div>
<i>To Do:</i>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<div class="reorderListDemo">
<ajaxToolkit:ReorderList ID="ReorderList1" runat="server"
PostBackOnReorder="false"DataSourceID="objCategories"
CallbackCssStyle="callbackStyle"
DragHandleAlignment="Left"ItemInsertLocation="End"
SortOrderField="itemPriority" >
<ItemTemplate>
<div class="itemArea">
<asp:Label ID="Label1" runat="server"
Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("ItemID"))) %>' />
<asp:Label ID="Label2" runat="server"
Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("ItemID", " - {0}"))) %>' />
</div>
</ItemTemplate>
<EditItemTemplate>
<div class="itemArea">
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("ItemID") %>' ValidationGroup="edit" />
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("ItemID") %>' ValidationGroup="edit" />
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("ItemID") %>' ValidationGroup="edit" />
</div>
</EditItemTemplate>
<ReorderTemplate>
<asp:Panel ID="Panel2" runat="server" CssClass="reorderCue" />
</ReorderTemplate>
<DragHandleTemplate>
<div class="dragHandle"></div>
</DragHandleTemplate>
<InsertItemTemplate>
<!-- bottom border is workaround for IE7 Beta issue where bg doesn't render -->
<div style="padding-left:25px; border-bottom:thin solid transparent;">
<asp:Panel ID="panel1" runat="server" DefaultButton="Button1">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ItemID") %>' ValidationGroup="add" /><asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Add" ValidationGroup="add" />
</asp:Panel>
</div>
</InsertItemTemplate>
</ajaxToolkit:ReorderList>
</div>
<asp:ObjectDataSource ID="objCategories" runat="server"
SelectMethod="GetAllCategories"InsertMethod="insertNewCat"
UpdateMethod="updateNewCat"
TypeName = "Category">
<UpdateParameters><asp:Parameter Name="ItemId" Type="Int32" />
</UpdateParameters>
</asp:ObjectDataSource>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
and here is the code of my class for that control:
public class Category
{
public Category()
{
}public void updateNewCat(Int32 itemId)
{
/*my code to update the item*/
}
public void insertNewCat(Int32 itemId)
{
CDatabaseTools DB = new CDatabaseTools("my connection string details", 0);String query = "insert into reorder (itemId, itemVal) values (" + itemId.ToString() + ", 'test')";
DB.updateDBFromQuery(query);
}
[DataObjectMethod(DataObjectMethodType.Select)]public DataSet GetAllCategories()
{
SqlConnection myConnection = new SqlConnection("my connection string details");
SqlDataAdapter ad = new SqlDataAdapter("SELECT * FROM reorder ", myConnection);DataSet ds = new DataSet();
ad.Fill(ds);
return ds;
}
}
How can I handle the reorder event ? It seems the problem is coming from there... Any help would be very appreciated :)