日期:2014-05-18  浏览次数:21055 次

关于GridView绑定数据
举例
C# code

//Income
public class Income
{
public Bank bank{get;set;}

}

//Bank
public class Bank
{
public int ID{get;set;}

public string Name{get;set;}
}
//返回List<Income>
...
...
数据库链接略
...
...
Income.bank=new Bank();
income.bank.Name=reader["Name"].toString();





绑定GridView的时候说Name不存在。求教啊


------解决方案--------------------
迷糊中~~~~
------解决方案--------------------
DataTable dt = new DataTable("Table_Order");
dt.Columns.Add("字段1", System.Type.GetType("System.String"));
dt.Columns.Add("字段2", System.Type.GetType("System.String"));

dr["字段1"] = "222";
dr["字段2"] = "222";

dr["字段1"] = "333";
dr["字段2"] = "333";

GridView.DataSource = dt;