BoundField bf = new BoundField();
bf.DataField = "FacuID";
bf.HeaderText = "<FacuID>";
GridView1.Columns.Add(bf);
this.GridView1.DataSource = SpecialtyManagerFactory.SpecialtyManager.SelectAll();
this.GridView1.DataBind();
SpecialtyManagerFactory.SpecialtyManager.SelectAll()
返回的是 List<Specialty>
public partial class Specialty{
private Guid specID;
private Faculty facuID;
private string specName;
}
public partial class Faculty
{
private Guid facuID;
private string facuName;
}
运行结果是:
在线等..
直接在.aspx页面的GridView里面 <Columns>集合是里加一个,<asp:BindField DataField="FacuID " HeaderText="FacuID "/></Columns>
bf.DataField = "Faculty.FacuID";
private Guid FacuID是私有的啊,你要加get set 方法啊。然后在gridview中绑定这个get的方法名就可以了啊。