【问题标题】:Binding values in Repeater using 'container.dataitem'使用“container.dataitem”在中继器中绑定值
【发布时间】:2013-10-22 10:19:17
【问题描述】:

lstGroup1是一个列表框ID,arraylist1是一个ArrayList。下面是从arraylist绑定值到repeater的代码。它工作正常。

lstGroup1.Items.Add(((ListItem)arraylist1[i]));

但我还需要将 arraylist 值绑定到转发器中。这可能吗?谁能帮忙..???

中继器 Aspx:

  <asp:Repeater ID="RptrSummary" runat="server" OnItemDataBound="RptrSummary_ItemDataBound" >
                                                <ItemTemplate>
                                                    <table cellpadding="10" cellspacing="10">
      <tr>
       <td>
       <asp:Label ID="lblSumName" runat="server" Text= '<%# DataBinder.Eval(Container.DataItem, "SUMMARY_NAME") %>'></asp:Label>

       </td>
 </table>
     </ItemTemplate>
        </asp:Repeater>

在这个中继器中,如果我简单地放入 Container.DataItem,那么 Arraylist 就会被绑定,但它在上面的 Eval.Container 中不起作用。

【问题讨论】:

  • @JackPettinger:当我把它作为“Container.DataItem”时它工作

标签: asp.net listbox repeater listboxitem listbox-control


【解决方案1】:

要将您的数组列表绑定到转发器,只需执行以下操作:

MyRepeater.DataSource = myArrayList;
MyRepeater.DataBind();

【讨论】:

  • :感谢您的回复。如果我单独放置“Container.DataItem”,则该值将绑定到中继器。如果我在上述方法中这样做,它无法正常工作。
猜你喜欢
  • 2011-01-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-11
相关资源
最近更新 更多