【发布时间】:2013-06-25 04:20:43
【问题描述】:
好吧,我第一次觉得我不得不发布,有很多关于数据网格的信息,但没有什么能以我理解的方式解释我需要什么。
dataBooks.DataSource = null;
dataBooks.AutoGenerateColumns = true;
dataBooks.DataSource = _Author.Books.ToList();
这将返回一个对象列表,但是我想添加另一列,我可以在其中调用 getType() 它将返回书籍格式。
当我将 autogeneratecolumns 更改为 false 时,我不知道如何绑定数据,所以我得到了一个空白列表。温柔点,这对你来说可能很明显,但我是新手。
我想调用一个 GetBookType() 方法,它会返回一个字符串。
public abstract partial class Book
{
public Book()
{
this.Orders = new HashSet<Order>();
}
public string AuthorName { get; set; }
public string Title { get; set; }
public double Price { get; set; }
public int Quantity { get; set; }
public int Year { get; set; }
public virtual Author Author { get; set; }
public virtual ICollection<Order> Orders { get; set; }
}
以及将返回类型字符串的部分类
公共抽象部分类 clsBook { 公共覆盖字符串 ToString() { 返回 this.Title + "\t" + this.Year + "\t" + this.Price + "\t" + this.Quantity + "\t" + this.GetType(); }
public abstract void EditDetails();
public abstract string GetBookType();
【问题讨论】: