ListView
コードビハインドから入力し、フィールドの作成方法を知りたいです。この例を見ましたが、 ListView
sフィールドを作成する唯一の方法がテーブルを使用することであるかどうかを確認したいと思います。そうでない場合、それを行う別の方法は何でしょうか?ListView
次のように、データソースのみを入力してみました。
ListView1.DataSource = ds;
ListView1.DataBind();
しかし、それは私にエラーを与えました:
ItemTemplateは、ListView'ListView1'で定義する必要があります。
使用するための最良の方法は何ListView
ですか?エラーは私が使用した場合にのみ発生しますListView1.DataBind();
PS:表示するのに必要な行は1つだけなので、誰かがよりも使用するためのより良いコントロールを持っている場合ListView
、私は読んでいます。
アップデート
今私はこのようにしようとしています:
<asp:ListView ID="ListView1" runat="server">
<LayoutTemplate>
<table border="0" cellpadding="1">
<tr style="background-color: #E5E5FE">
<th align="left"><asp:LinkButton ID="lnkResp" runat="server"></asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkProj" runat="server"></asp:LinkButton></th>
<th align="left"><asp:LinkButton ID="lnkFunc" runat="server"></asp:LinkButton></th>
<th<></th>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td><asp:Label runat="server" ID="lblResp"><%#Eval("responsavel") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblProj"><%#Eval("projeto") %></asp:Label></td>
<td><asp:Label runat="server" ID="lblFunc"><%#Eval("funcionalidade") %></asp:Label></td>
</tr>
</ItemTemplate>
</asp:ListView>
しかし、新しいエラーが発生 しました。
An item placeholder must be specified on ListView 'ListView1'.
Specify an item placeholder by setting a control's ID property to "itemPlaceholder".
The item placeholder control must also specify runat="server".