foreach 문으로 ListView를 반복하려고하는데 항목의 하위 항목을 가져올 수 없습니다. For 문으로 성공하지 못했습니다. IntelliSense는 두 가지 방법으로 제안하지 않습니다. 뒤에반복하는 동안 ListView의 하위 항목에 액세스 할 수 없습니다.
코드 :
protected void btnNext_Click(object sender, EventArgs e)
{
foreach (ListViewItem item in ListView1.Items)
{
item. *(here a should get the Subitems)*
}
}
ASPX
<asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1">
<LayoutTemplate>
<table>
<tr>
<th>Customer</th>
<th>Item No</th>
</tr>
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("CustomerName") %>
</td>
<td>
<%# Eval("Item") %>
</td>
</tr>
</ItemTemplate>
</asp:ListView>