• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

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

        

Using system.data;

Using system.data.sqlclient;

        

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 = ‘system.data’ % >

<body>

<h2>Satya technologies  </h2>

<div>

<% HTML Begin Form ();%>

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

<tr>

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

</tr>

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

<tr>

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

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

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

</tr>

<% } %>

</table>

<% HTML. End form (); %>

</div>

</body>

 

Summary
Review Date
Reviewed Item
Entity framework & Model class
Author Rating
5

“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 info@tekslate.com, 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 *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.