使用LayoutTemplate,您可以定義列,然後使用OnLayoutCreated事件隱藏特定的列。
<asp:ListView ID="ListView1" class="lv" runat="server" DataSourceID="SqlDataSource1"
onprerender="ListView1_PreRender"
onselectedindexchanged="ListView1_SelectedIndexChanged"
style="text-align: left" OnLayoutCreated="OnLayoutCreated">
<LayoutTemplate>
<table id="itemPlaceholderContainer">
<tr>
<td><asp:Label id="columnToHide" runat="server" Text="Column 1" /></td>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%#Eval("name")></td>
</tr>
</ItemTemplate>
然後在後臺代碼:
protected void OnLayoutCreated(object sender, EventArgs e)
{
this.ListView1.FindControl("columnToHide").Visible = false;
}
你使用C#或VB.NET? – Solaflex 2013-05-06 14:20:58
C#@ Solaflex :) – IceDawg 2013-05-06 17:02:20
您是否嘗試使用ItemTemplate並且沒有標題行? – Nabheet 2013-05-06 17:59:37