我是 ASP.NET 的新手,正在尝试创建重复的 detailsview 类型格式。我的意思是第一列是标题类型列,后续列是数据记录。
记录 Rec1 Rec 2 Rec3
标题 A Fld A Fld A Fld A
标题 B Fld B Fld B Fld B
基于此示例,我尝试了以下几个迭代:
<asp:ListView ID="ListView2" runat="server" DataKeyNames="FldA" DataSourceID="EntityRecordSource" GroupItemCount="3">
<LayoutTemplate>
<table id="Table1" runat="server">
<tr id="Tr21" runat="server">
<td id="Td1" runat="server">
<table id="Table2" runat="server" border="0" style="">
<tr id="Tr1" runat="server" style="">
<th id="Th1" runat="server"></th>
</tr>
<tr id="Tr2" runat="server" style="">
<th id="Th2" runat="server">FldA</th>
</tr>
<tr id="Tr3" runat="server" style="">
<th id="Th3" runat="server">FldB</th>
</tr>
<tr id="Tr4" runat="server" style="">
<th id="Th4" runat="server">FldC</th>
</tr>
</table>
</td>
<td>
<table>
<asp:PlaceHolder runat="server" ID="groupPlaceHolder"></asp:PlaceHolder>
</table>
</td>
</tr>
<tr id="Tr22" runat="server">
<td id="Td2" runat="server" style="">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<GroupTemplate >
<tr id="Tr1" runat="server" style="">
<asp:PlaceHolder runat="server" ID="itemPlaceHolder1"></asp:PlaceHolder>
</tr>
<tr id="Tr2" runat="server" style="">
<asp:PlaceHolder runat="server" ID="itemPlaceHolder2"></asp:PlaceHolder>
</tr>
<tr id="Tr3" runat="server" style="">
<asp:PlaceHolder runat="server" ID="itemPlaceHolder3"></asp:PlaceHolder>
</tr>
</GroupTemplate>
<ItemTemplate>
<td>
<asp:Label ID="FldALabel" runat="server" Text='<%# Eval("FldA") %>' />
</td>
<td>
<asp:Label ID="FldBLabel" runat="server" Text='<%# Eval("FldB") %>' />
</td>
<td>
<asp:Label ID="FldCLabel" runat="server" Text='<%# Eval("FldC") %>' />
</td>
</ItemTemplate>
</asp:ListView>
但是,这会导致错误说明:
System.Web.UI.HtmlControls.HtmlTableCellCollection 必须具有“System.Web.UI.HtmlControls.HtmlTableCell”类型的项目。“asp:PlaceHolder”的类型为“System.Web.UI.WebControls.PlaceHolder”。
在此先感谢您的帮助。