Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法使用EF、LINQ将网站中的数据打印到列表视图中_C#_Asp.net_.net_Linq To Entities_Entity Framework 5 - Fatal编程技术网

C# 无法使用EF、LINQ将网站中的数据打印到列表视图中

C# 无法使用EF、LINQ将网站中的数据打印到列表视图中,c#,asp.net,.net,linq-to-entities,entity-framework-5,C#,Asp.net,.net,Linq To Entities,Entity Framework 5,我有一个网站,它使用EF构建DB和LINQ来访问数据。我正在尝试将数据打印到列表视图中,但没有打印任何内容,我不知道为什么 标记: <asp:ListView ID="lvSearchResults" OnPagePropertiesChanged="lvSearchResults_PagePropertiesChanged" runat="server"> <LayoutTemplate> <table style="width: 100%

我有一个网站,它使用EF构建DB和LINQ来访问数据。我正在尝试将数据打印到列表视图中,但没有打印任何内容,我不知道为什么

标记:

<asp:ListView ID="lvSearchResults" OnPagePropertiesChanged="lvSearchResults_PagePropertiesChanged" runat="server">
    <LayoutTemplate>
        <table style="width: 100%" border="1">
            <tr style="text-align:center;">
                <td>Item Name</td>
                <td>Release Region</td>
                <td style="width: 100px">Factory Sealed</td>
                <td style="width: 50px">Item Details</td>
                <td style="width: 50px">Edit Item</td>
            </tr>

            <tr id="itemPlaceHolder" runat="server" />
        </table>

        <asp:DataPager ID="dpSearchResults" PagedControlID="lvSearchResults" PageSize="10" runat="server">
            <Fields>
                <asp:NextPreviousPagerField ButtonType="Button" ShowNextPageButton="false" ShowFirstPageButton="true" ShowLastPageButton="false" ShowPreviousPageButton="true" />
                <asp:NumericPagerField ButtonCount="10" />
                <asp:NextPreviousPagerField ButtonType="Button" ShowNextPageButton="true" ShowFirstPageButton="false" ShowLastPageButton="true" ShowPreviousPageButton="false" />
            </Fields>
        </asp:DataPager>
    </LayoutTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <%#:Item.Name%>
            </td>
            <td>
                <%#:Item.Region%>
            </td>
            <td style="text-align: center;">
                <%#:Item.Condition%>
            </td>
            <td>
                <asp:Button ID="btnSelect" Text="View Details" PostBackUrl="/Items/<%#:ItemName%>" runat="server" />
            </td>
            <td>
                <asp:Button ID="btnEdit" Text="Edit Item" PostBackUrl="/Edit/<%#:ItemName%>" runat="server" />
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>

解决方案是添加Eval命令,以使工作代码

                               <td>
                                <%#:Eval("Name")%>
                            </td>

                            <td>
                                <%#:Eval("Region")%>
                            </td>

                            <td style="text-align: center;">
                                <%#:Eval("Condition")%>
                            </td>
                               <td>
                                <%#:Eval("Name")%>
                            </td>

                            <td>
                                <%#:Eval("Region")%>
                            </td>

                            <td style="text-align: center;">
                                <%#:Eval("Condition")%>
                            </td>