【问题标题】:AJAX.NET Reorderlist Control - "It does not a DataSource and does not implement IList."AJAX.NET Reorderlist 控件 - “它不是数据源,也没有实现 IList。”
【发布时间】:2010-09-12 19:42:49
【问题描述】:
尝试在我的 ReorderList 控件中重新排序项目时,我不断收到此错误。
“重新排序失败,详情见下文。
无法访问数据源。它不是 DataSource,也没有实现 IList。”
我现在正在将数据源设置为 DataTable,并且目前正在尝试使用 ArrayList 数据源,但由于互联网上其他地方的 this post 而我不鼓励。该控件存在于更新面板中,但没有订阅其他事件。 OnItemReorder 事件应该有什么特别之处吗?只是对它的工作原理感到困惑。
我的问题是,有人对这个问题有任何直接的经验吗?
【问题讨论】:
标签:
c#
.net
asp.net
asp.net-ajax
reorderlist
【解决方案1】:
我想通了。我将 DataTable 转换为 ArrayList,然后绑定到控件。感谢大家阅读!
【解决方案2】:
我收到了同样的错误信息。就我而言,这是因为我试图将 SortOrder 字段设置为非数字字段。控件只能按类型为整数(或类似)的字段对列表进行排序。不是字符串或日期。
【解决方案3】:
我过去成功使用过它,没有太多问题(绑定到列表)。您能否发布一些关于您在前端和代码隐藏中的内容的 sn-ps?
【解决方案4】:
<cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400" >
<ItemTemplate>
<div class="sortablelineitem">
<a href="#" class="albmCvr" id="song13">
<img src="/images/plalbumcvr.jpg" alt="Name of Album" class="cvrAlbum" width="10"
height="10" />
Song 1 <span>by</span> Artist 1 </a>
<asp:ImageButton ID="ImageButton13" runat="server" ImageUrl="/images/btn_play_icon.gif"
ToolTip="Play Clip" CssClass="playClip" />
</div>
</ItemTemplate>
<EditItemTemplate>
<h1>WHOA THE ITEM IS BEING DRAGGED!!</h1>
</EditItemTemplate>
<ReorderTemplate>
<div style="width:400px; height:20px; border:dashed 2px #CCC;"></div>
</ReorderTemplate>
<DragHandleTemplate>
<div style="height:15px; width:15px; background-color:Black;"></div>
</DragHandleTemplate>
<EmptyListTemplate>
There are no items in this playlist yet...
</EmptyListTemplate>
</cc1:ReorderList>
</ContentTemplate>
</asp:UpdatePanel>
是我的前端,而在后端我只是获取一个数据表对象并将其绑定到非回发的 OnLoad...
ReorderList1.DataSource = ds.Tables[1];
ReorderList1.DataBind();
商品重新排序时是否需要重新设置数据源?
【解决方案5】:
当我尝试排序的表没有分配给 DataKeyField 的初始值时,我发现了同样的错误。当它在我的测试环境中工作时,这让我把头发扯掉了,但当我把它推到现场时却没有。我还注意到它在我的网络服务器控制台上抛出了一个带有相同消息的对话框。这有一个中止/重试/忽略按钮设置,因此有效地杀死了一切。现在这太粗鲁了!
解决方案是在使用控件之前对字段值进行连续编号。