HI,
In mvc u have a three layer
create the class in three layer:
presentation Layer:
In this layer call the Business Layer method
Business Layer:
In this layer call the dataaceess layer method
Dataaccess Layer:
It exectues the query.
All this methods are returns a value through Dataset
Example:
Presentation layer:
public partial class website1 : System.Web.UI.Page
{
Businesslayerclass objbusiness=new Businesslayerclass();
public void page_load()
{
}
public void Gridviewbinddata()
{
Dataset ds=new Dataset();
ds=objbusiness.GridviewBind();//call the businesslayer method
Gridview1.Datasource=ds;
Gridview1.DataBind();
}
}
BusinessLayer://class file
public class Businesslayerclass
{
Dataacesslayerclass objData=new Dataacesslayerclass();
public Dataset GridviewBind()
{
Dataset ds=new Dataset();
ds=objData.GridViewData();//call the dataaccesslayer method
return ds;
}
}
DataaacessLayer://class file
public class DataaacessLayer
{
sqlconnection con=new sqlconnection("database path");
sqlcommand cmd=new sqlcommand();
sqlDataAdapter da=new SqlDataAdapter();
public Dataset GridviewData()
{
Dataset ds=new Dataset();
con.open();
string StrQuery="select * from employeedetail";//query
ds=cmd.ExecuteNonQuery(StrQuery);
da.fill(ds);
return ds;//returns the dataset value to the business layer
}
i hope it helps you.........
Regards
Kavi.n
Meenakshi, if this helps please login to Mark As Answer. | Alert Moderator