AJAX.NET 重新排序列表控件 - “它不是数据源,也不实现 IList。”

发布于 2024-07-06 13:46:41 字数 417 浏览 4 评论 0原文

当尝试重新排序 ReorderList 控件中的项目时,我不断收到此错误。

“重新排序失败,请参阅下面的详细信息。

无法访问数据源。它不是 DataSource,也没有实现 IList。”

我现在正在将数据源设置为 DataTable,并且目前正在尝试使用 ArrayList 数据源,但由于 此帖子在互联网上的其他地方。 该控件存在于更新面板中,但没有订阅其他事件。 OnItemReorder 事件应该有什么特别的吗? 只是对其如何工作感到困惑。

我的问题是,有人对这个问题有直接的经验吗?

I keep getting this error when trying to re-order items in my ReorderList control.

"Reorder failed, see details below.

Can't access data source. It does not a DataSource and does not implement IList."

I'm setting the datasource to a DataTable right now, and am currently trying to use an ArrayList datasource instead, but am discouraged because of this post on the internet elsewhere. The control exists within an update panel, but no other events are subscribed to. Should there be something special with the OnItemReorder event? Just confused as to how it works.

My question is, does anyone have any direct experience with this issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

分开我的手 2024-07-13 13:46:41

我想到了。 我将 DataTable 转换为 ArrayList,然后绑定到控件。 感谢大家的阅读!

I figured it out. I converted the DataTable to an ArrayList then bound to the control. Thanks everyone for reading!

挽容 2024-07-13 13:46:41

我收到了同样的错误消息。 就我而言,发生这种情况是因为我试图将 SortOrder 字段设置为非数字字段。 该控件只能按类型为整数(或类似)的字段对列表进行排序。 不是字符串或日期。

I got the same error message. In my case it happened because I was trying to set the SortOrder field to a non-numerical field. The control can sort the list only by a field whose type is integer (or similar). Not a string or date.

蘸点软妹酱 2024-07-13 13:46:41

我过去成功地使用过它,没有太多问题(绑定到列表)。 您能发布一些前端和代码隐藏的片段吗?

I've used it successfully in the past without much issue (binding to a List). Could you post some snippets of what you have in your front-end and code-behind?

独守阴晴ぅ圆缺 2024-07-13 13:46:41
                        <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();

当项目重新排序时,我是否需要再次设置数据源?

                        <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>

is my Front end, and in the back end I'm just getting a datatable object and binding it OnLoad of a Non postback...

ReorderList1.DataSource = ds.Tables[1];
ReorderList1.DataBind();

Do I need to set the datasource again when the items are reordered?

指尖微凉心微凉 2024-07-13 13:46:41

我发现当我尝试排序的表没有分配给 DataKeyField 的初始值时会导致相同的错误。 当它在我的测试环境中工作时,这让我抓狂,但当我将其投入使用时却不然。 我还注意到它在我的网络服务器控制台上抛出了一个包含相同消息的对话框。 这有一个中止/重试/忽略按钮设置,因此有效地杀死了一切。 现在这太粗鲁了!

解决方案是在使用控件之前对字段值进行连续编号。

I found the same error caused when the table I was trying to sort had no initial values allocated to the DataKeyField. This had me tearing my hair out as it worked in my test environment, but not when I pushed it live. I'd also note that it threw a dialog box with the same message ON MY WEB SERVER CONSOLE. This had an abort/retry/ignore button set so effectively killed everything. Now that's just rude!

The solution was just to consecutively number the field values before using the control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文