Group Discounts available for 3+ students and Corporate Clients

Display data using entity framework model class

Display data using entity framework model class

Performing the same example by writing code in model class

Sol :-    Create a new view in home folder  (sample)

Creating MODEL CLASS :-

  • Go to solution explorer
  • Go to model folder
  • Double click on account model.c
  • Click on + symbol of model
  • Create a class with name sample model
Public class Sample model ()
Public data set ds;
Public sample model ()
Sql connection  con = new sql connection (“”);
String s= “select * from emp details “;
Sql data adapter da = new sql data adapter (s, con);
Data set ds = new data set ();
Da.fill (ds,’x’);

2Go to home controller .cs

Aspired to become an ? 
Explore the post to discover the know-hows on Training.

2write the following code for action method sample ();

Public action result sample ()
Models.sample1 model obj1 = new models.sample1 model ();
List <data row> r = row list <data row> ();
Foreach (Dat row x in obj1.ds.tables [0].Rows)
R .add (x);
View data [‘R’] = R;
Return view ();

2Go to sample 1 .aspx and write the following code:

<% @ import name space = ‘’ %>

<h2>satya technologies </h2>


<% HTML. Begin form () ; %>


2Change the action name in global.aspx and run the application and check.

For indepth understanding click on


“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at, we will update the article in 24 hours.”

0 Responses on Display data using entity framework model class"

Leave a Message

Your email address will not be published. Required fields are marked *


Please Enter Your Details and Query.
Three + 6