【发布时间】:2013-04-12 17:19:18
【问题描述】:
下面是我的代码
List<test> Students = new List<test>(){
new test() { name = "Jack", imgpath = "15", Des = "100" },
new test() { name = "Smith", imgpath = "15", Des = "101" },
new test() { name = "Smit", imgpath = "1", Des = "102" }
};
GridView1.DataSource = Students;
GridView1.DataBind();
我的班级是:
public class test
{
public string name;
public string imgpath;
public string Des;
}
但它给了我错误“在选定的数据源上找不到名为'name'的字段或属性。”
那么怎么解决呢。我不知道我的代码有什么问题。
谢谢
【问题讨论】:
-
您需要从 ASPX 页面粘贴代码以进行 Gridview 声明。
-
您在 Gridview 中使用 Eval。如果是这样,请确保字段名称。
标签: asp.net