How to write a Class for retrieving IEnumerable Objects in EF and C#
I use c# asp.net 4 web forms and ef4.
In my Code Behind I use several times this code below to bind and rebind (for refresh) e GridView after an insertion or other operations completed using EF objects.
Using a simple gridview.DataBind(); does not work because I call EF programmatically so I thought to use a Class to keep in memory this code that can create Objects for my GridView and call it how many time I need in my code avoiding redundancy.
I开发者_开发知识库Enumerable<CmsContent> queryContents =
myCurrentSlot.CmsContents.Where(x => x.IsPublished == true);
uxManageContents.DataSource = queryContents;
uxManageContents.DataBind();
Can you help me to write this Class? Or do you know a batter way to Refresh the gridview after EF executing some commands? how to do it?
Please remember that I do use any data source web control for the gridview but i bind it programmatically.
Use ObjectDataSource instead of codebehind.
精彩评论