Search

Wednesday, November 4, 2015
0 comments

Get data From Database table using EDMX in ASP.NET

10:23 PMWednesday, November 4, 2015
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();  
   }  
Protected by Copyscape Online Copyright Protection Software

0 comments :

Post a Comment

 
Toggle Footer
Top