Display data using entity framework model class

Ratings:
(4)
Views:739
Banner-Img
  • Share this blog:

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 ASP.net ? 
Explore the post to discover the know-hows on ASP.net 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 = ‘system.data’ %> <h2>satya technologies </h2> <div> <% HTML. Begin form () ; %>   2Change the action name in global.aspx and run the application and check.

For indepth understanding click on

 

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox