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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
naura paxPosted Nov 9, 2009, 2:35 AM
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 ChoudharyPosted Nov 9, 2009, 3:06 AM
Products p=new Products();
P.CategoryID=125;
P.Query.Load();
GridView1.DataSource=p.DefaultView();
GridView1.DataBind();
====================================
Dont forget to mark it as answer Please :)