テーブル表示をより細かく制御できるように、 aGridView
を aに変換しようとしています。ListView
ここGridView
で定義されているように正常に動作し、データを正しく表示します。
<asp:GridView ID="gvService" runat="server"
AllowPaging="True"
AutoGenerateColumns="False"
DataKeyNames="ID"
DataSourceID="objService">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="ServiceType" HeaderText="Type" />
</Columns>
</asp:GridView>
これを に変換するListView
と、ページに HTML がまったくレンダリングされません。私はそれらを並べて配置しましたGridView
が、作品ListView
は表示されません。
<asp:ListView ID="lvService" runat="server"
DataSourceID="objService">
<LayoutTemplate>
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Type</th>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><%# Eval("ID") %></td>
<td><%# Eval("Name") %></td>
<td><%# Eval("ServiceType") %></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr>
<td><%# Eval("ID") %></td>
<td><%# Eval("Name") %></td>
<td><%# Eval("ServiceType") %></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
こちらがObjectDataSource
<asp:ObjectDataSource ID="objService" runat="server"
EnablePaging="true"
TypeName="My.Data.DataSource.ServiceDataSource" DataObjectTypeName="My.Data.Service.ServiceSearch"
SelectMethod="Search"
SelectCountMethod="SearchCount">
<SelectParameters>
<asp:ControlParameter ControlID="tbSearch" Name="Search" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>
ここで基本的な何かが欠けているように感じます。なぜGridView
移入するのにListView
しないのかについての考えはありますか?
コード ビハインドでコントロールを手動でDataBind()する必要がありますか?