[英]ASP simple gridview with paging
在我的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
用作訪問說明符。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.