ASP.NET' GridView'不包含' VirtualItemCount'的定义

时间:2018-02-12 17:04:52

标签: c# asp.net gridview webforms

我试图在ASP.NET Web窗体GridView中使用属性VirtualItemCount进行自定义分页,它给了我这个错误

Severity    Code    Description Project File    Line    Suppression State
Error   CS1061  'GridView' does not contain a definition for 'VirtualItemCount' and no extension method 'VirtualItemCount' accepting a first argument of type 'GridView' could be found (are you missing a using directive or an assembly reference?)   dms D:\project\Screen\ToDoList.aspx.cs  100 Active

当我创建新项目时,它的工作正常,但在我当前的项目中,它似乎没有定义,我搜索了很多没有类似于我的情况。

我是否需要添加某些装配参考或缺少设置?

<asp:GridView ID="GridView1" runat="server" CssClass="Grid"
    PageSize="10" 
    AllowPaging="true"
    AutoGenerateColumns="false" OnPageIndexChanging="GridView1_PageIndexChanging">
    <AlternatingRowStyle />
    <Columns>
        <asp:BoundField DataField="Name" HeaderText="Name" />
        <asp:BoundField DataField="Date" HeaderText="Date" />
        <asp:TemplateField>
            <ItemTemplate>
                <input type="button" value="Edit" class="button" />
                <input type="button" value="delete" class="button" />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

看起来像这样

enter image description here

这些是我的设置

enter image description here

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

我只是转到Properties -> Application并将Target Framework.NET Framework 4更改为.NET Framework 4.5并且有效