0
我想使用嵌套的ListView控件提到this article的外觀。但是,在我的情況下,我無法使用EntityDataSource控件,因此我手動綁定了數據。如何將一個標記添加到ListViewItem?
我的表:
Categories
PK: UniqueId, Guid
Name, string
ParentId, Guid
<asp:ListView ID="CategoryList" runat="server"
onitemdatabound="CategoryList_ItemDataBound">
<LayoutTemplate>
<table>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td colspan="2"><%# Eval("Name") %></td>
</tr>
</ItemTemplate>
</asp:ListView>
protected void Page_Load(object sender, EventArgs e)
{
using (PractiseEntities context = new PractiseEntities()) {
var result = from categories in context.Categories
select categories;
CategoryList.DataSource = result;
CategoryList.DataBind();
}
}
我想要的子類別有縮進由<td>
標籤添加到「的ParentId」不爲空的項目。而我的問題是如何編輯ItemDataBound事件中生成的html標籤?
THX了很多,它的作品! – 2009-05-04 15:59:39