.aspx
<body>
<form id="form1" runat="server">
<fieldset id="Field1" runat="server">
<legend>Employee</legend>
<center>
<table>
<tr>
<td>Ename:</td>
<td><asp:TextBox ID="txtename" runat="server"></asp:TextBox></td>
</tr>
<tr><td>Designation</td>
<td><asp:TextBox ID="txtDesignation"
runat="server"></asp:TextBox></td>
</tr>
<tr><td>Location</td>
<td><asp:TextBox ID="txtlocation"
runat="server"></asp:TextBox></td>
</tr>
<tr><td colspan="2" class="style1">
<asp:Button ID="btnsubmit"
runat="server"
Text="Submit"
onclick="btnsubmit_Click"
/>
<asp:Label ID="lblmessage" runat="server" Text="[lblMsg]" Visible="False">
</asp:Label>
</td>
</tr>
<tr>
<td colspan="2">
<asp:GridView ID="gdv" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="Ename"
DataField="ename"
/>
<asp:BoundField HeaderText="Designation"
DataField="Designation"
/>
<asp:BoundField HeaderText="Location"
DataField="Location"
/>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</center>
</fieldset>
</form>
</body>
Helper
Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
namespace SqlHelper
{
public class Helper
{
//Sql connection
SqlConnection conn;
public int insert(string query)
{
string connect = ConfigurationManager.ConnectionStrings["Sqlcon"].ToString();
conn = new SqlConnection(connect);
SqlCommand com = new
SqlCommand(query, conn);
//Connection Open
conn.Open();
int x = com.ExecuteNonQuery();
//Connection Close
conn.Close();
return x;
}
public DataSet
load(string querry)
{
string connect = ConfigurationManager.ConnectionStrings["Sqlcon"].ToString();
conn = new SqlConnection(connect);
SqlDataAdapter da = new
SqlDataAdapter(querry, conn);
DataSet ds=new DataSet();
da.Fill(ds);
return ds;
}
}
}
Business
Object layer(BOL)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BusinessObjectLayer
{
public class BOL
{
public BOL()
{
}
string ename=string.Empty;
string designation = string.Empty;
string location = string.Empty;
public string Ename
{
get { return ename; }
set { ename = value;
}
}
public string
Designation
{
get { return
designation; }
set { designation = value;
}
}
public string
Location
{
get { return
location; }
set { location = value;
}
}
}
}
Business
Access layer(BAL)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessObjectLayer;
using SqlHelper;
namespace BusinessAccessLayer
{
public class BAL
{
public int
insertvalue(BOL objBOL)
{
Helper Objhelper = new
Helper();
string query = "Insert
Into dsp values('" +
objBOL.Ename + "','"+objBOL.Designation+"','"+objBOL.Location+"')";
return Objhelper.insert(query);
}
public object
loadvalues()
{
Helper Objhelper = new
Helper();
string querry = "select
*from dsp";
return Objhelper.load(querry);
}
}
}