Group Discounts available for 3+ students and Corporate Clients

Entity framework & Model class

Example to display the data in mvc with out using entity frame work(With out using model class)

Create a new mvc2 application 2Add a new view page in home folder(sample)2Go to home controller.cs2Include the following the namespace





2create the an action with name


2write the following code


Public Action Result Sample ()


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’);

List <data row> r = new list <data row> ();

For each (data row . x in ds. Tables [0].rows)

R.add ();

View data [“R”] = R;

Return view ();



2Go to sample view

2Write the following code

<% @ Import  name space = ‘’ % >


<h2>Satya technologies  </h2>


<% HTML Begin Form ();%>

<table border = ‘2’ align = ‘center’ >


<th>EMP id </th> <th> E NAME </th><th>E sal </th>


<% for each (var x in (1 enumerable  <Data row> view data [‘R’])  I %)>


<td><% : HTML. Encode (x [0]%)></td>

<td><% : HTML. Encode (x [1]%)></td>

<td><% : HTML. Encode (x [2]%)></td>


<% } %>


<% HTML. End form (); %>




“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 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