ASP简单的gridview与分页
本文关键字:分页 gridview 简单 ASP | 更新日期: 2023-09-27 18:11:52
在我的aspx中我有:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="True">
</asp:GridView>
我有一个非常简单的类:
class ItemTable
{
public ItemTable(string mc, string dt)
{
this.Machinecode = mc;
this.Datetime = dt;
}
string Machinecode { get; set; }
string Datetime { get; set; }
}
在我的代码中,我有:
List<ItemTable> infos = new List<ItemTable>();
//Some code for add item in infos...
GridView1.DataSource = infos;
GridView1.DataBind();
但是我有这个错误:
id为'GridView1'的GridView的数据源没有任何用于生成列的属性或属性。确保您的数据源有内容。
像这样更改您的属性为public
class ItemTable
{
public ItemTable(string mc, string dt)
{
this.Machinecode = mc;
this.Datetime = dt;
}
public string Machinecode { get; set; }
public string Datetime { get; set; }
}
当没有提及访问指示符时,取private
作为访问指示符