[英]Get the current bounded object in a ListView's ItemTemplate
我希望能夠在ListView
控件的ItemTemplate
中獲取當前綁定對象。
這是我想要做的一個例子:
<asp:ListView ID="UserList" runat="server">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
//How can I get the current bound object in here?
</ItemTemplate>
</asp:ListView>
您可以通過DataItem訪問它:
<%# DataBinder.Eval(Container.DataItem, "myPropertyName")%>'
如果你想要一個文本框,例如:
<asp:Label ID="MyProp" runat="server" Text='<%#Eval("myPropertyName") %>' />
如果你只想要完整的對象:
<%# (MyType)Container.DataItem %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.