Hi,
In my BLL i return an object of Type Employee (this is not a data table)... how do i bind this object to the DataGridView so that i can view the object's field values?
cheers
How do i bind an Object to the DataGridView?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

naura paxRank #2,843 · 502 reputationPosted Nov 8, 2009, 9:35 PM EST
List
for(int i=0;i
Employee emp=new Employee();
// set fields of emp like id, name
empList.Add(emp);
}
in your form set grd.DataSource=empList; // empList returned by your BLL function.
If you need to hide some properties then implement this Interface in your Employee class:
System.ComponentModel.INotifyPropertyChanged
and set this attribute on the property eg:
[Browsable(false)]
public int MiscPurchaseInvoiceID
{
get { return m_MiscPurchaseInvoiceID; }
set
{
m_MiscPurchaseInvoiceID = value;
OnPropertyChanged("MiscPurchaseInvoiceID");
}
}
Amit ChoudharyRank #145 · 15.8K reputationPosted Nov 8, 2009, 10:06 PM EST
Products p=new Products();
P.CategoryID=125;
P.Query.Load();
GridView1.DataSource=p.DefaultView();
GridView1.DataBind();
====================================
Dont forget to mark it as answer Please :)