How can i return IEnumarable data from function in GridView with Entity FrameWork?
- by programmerist
protected IEnumerable GetPersonalsData()
{
// List personel;
using (FirmaEntities firmactx = new FirmaEntities())
{
var personeldata = (from p in firmactx.Personals select new { p.ID, p.Name, p.SurName });
return personeldata.AsEnumerable();
}
}
i wan to send GetPersonelData() into GridView DataSource. Like That:
gwPersonel.DataSource = GetPersonelData();
gwPersonel.DataBind();
it monitored to me on : gwPersonel.DataBind(); this error:
"The ObjectContext instance has been disposed and can no longer be used for operations that require a connection."