Get data From Database table using EDMX in ASP.NET

In this article, I will show you, how to get data from Database table using EDMX file. Actually EDMX reduces lots of codes, you can see this article which contains lots of codes. EDMX file provides model as well as context class. By using public property of context class, we can communicate with the table.  Before copy this code, first to add EDMX file in solution.

Get data From Database table using EDMX in ASP.NET


Source code

   <form id="form1" runat="server">  
   <div>  
     <asp:GridView ID="GridView1" runat="server">  
     </asp:GridView>  
   </div>  
   </form>  


Code Behind 

   private void loadgrid()  
   {  
     //throw new NotImplementedException();  
     dbEntities dbe = new dbEntities();  
     var item = dbe.usertables.ToList();  
     GridView1.DataSource = item;  
     GridView1.DataBind();  
   }  
Get data From Database table using EDMX in ASP.NET Get data From Database table using EDMX in ASP.NET Reviewed by Jacob Lefore on November 04, 2015 Rating: 5

No comments