AjaxControlToolkit Accordion 和数据绑定
我正在使用手风琴的 HeaderTemplate 和 ContentTemplate 控制并将其绑定到数据表。由于某种原因它没有 显示任何数据。如果我将数据表绑定到数据列表,它的工作原理如下 预计,这是一个已知问题还是我完全在做某事 错误的。我在后面的代码中绑定了手风琴控件,如果这样的话 有什么区别。这是代码:
<cc1:Accordion ID="databoundaccordion" runat="server" AutoSize="None"
HeaderCssClass="articleHeader" HeaderSelectedCssClass="articleHeaderSelected"
ContentCssClass="articleBody" FadeTransitions="true"
SuppressHeaderPostbacks="true" RequireOpenedPane="true"
TransitionDuration="250" FramesPerSecond="40">
<HeaderTemplate>
<%# DataBinder.Eval(Container.DataItem, "name")%>
</HeaderTemplate>
<ContentTemplate>
<p>Content goes here</p>
<a href="Articles.aspx">Go</a>
</ContentTemplate>
并在后面的 C# 代码中:
databoundaccordion.DataSource = presenter.getDataTable();
databoundaccordion.DataBind();
I'm using the HeaderTemplate and the ContentTemplate of the Accordion
control and binding it to a datatable. For some reason it doesn't
display any data. If I bind the datatable to a datalist it works as
ecpected, is this a known issue or am i doing something completely
wrong. I'm binding the accordion control in the code behind if this
makes any difference. Here is the code:
<cc1:Accordion ID="databoundaccordion" runat="server" AutoSize="None"
HeaderCssClass="articleHeader" HeaderSelectedCssClass="articleHeaderSelected"
ContentCssClass="articleBody" FadeTransitions="true"
SuppressHeaderPostbacks="true" RequireOpenedPane="true"
TransitionDuration="250" FramesPerSecond="40">
<HeaderTemplate>
<%# DataBinder.Eval(Container.DataItem, "name")%>
</HeaderTemplate>
<ContentTemplate>
<p>Content goes here</p>
<a href="Articles.aspx">Go</a>
</ContentTemplate>
and in the c# code behind:
databoundaccordion.DataSource = presenter.getDataTable();
databoundaccordion.DataBind();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将 Accordion 绑定到 DataTable 对象时会遇到困难。
相反,通过将其转换为 DataTableReader 来执行以下操作,它应该可以正常工作:
这是带有示例数据的另一个示例:
You will have difficulties binding an Accordion to a DataTable object.
Instead, do the following by converting it into a DataTableReader and it should work just fine:
Here's another example with sample data:
我刚刚构建了一个运行良好的简单示例。
而不是使用
Databinder.Eval(Container.Item, "name")
我使用Eval("name")
这似乎适用于简单的示例,我将在何时更新我已经用我的工作代码进行了测试。
I have just built a simple example which works fine.
rather than using
Databinder.Eval(Container.Item, "name")
I usedEval("name")
this seems to work with the simple example, I will update when I've tested with my working code.