0

このコードを実行している間、<%Eval( "Firstname")%>で例外が発生しています。例外メッセージは次のとおりです。「Eval()、XPath()、Bind()などのデータバインディングメソッドは、データバインドされたコントロールのコンテキスト。」何をすべきか..私のコードは次のとおりです

<div>This is repeater
         <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
         <HeaderTemplate>
         <table>
         <tr>
            <th>FirstName</th>
            <th>LastName</th>
            <th>City</th>
          </tr>
         </HeaderTemplate>
         <ItemTemplate>
         <tr>
         <td><% Eval("FirstName")%></td>
         <td><% Eval("LastName")%></td>
         <td><% Eval("City")%></td>
         </tr>
         </ItemTemplate>
         <FooterTemplate>
         </table>
         </FooterTemplate>
         </asp:Repeater>
         <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
             ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
             SelectCommand="SELECT * FROM [Employees]">
         </asp:SqlDataSource>
    </div>
4

2 に答える 2

2

データバインディングを介してデータを出力するには、データバインディング式の構文を使用する必要があります

<%# Eval("FieldName")%>
于 2011-02-18T05:44:03.803 に答える
2

私はあなたが#シンボルを逃していると思います

試す:

<%# Eval("FirstName") %>
于 2011-02-18T05:44:59.187 に答える