3tier architecture example to insert and bind data in gridview
table
Presentation(User Interface)
Source Code for above design
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="auto-style2">
<strong>3Tier Example</strong></div>
<table class="auto-style1">
<tr>
<td>Name</td>
<td>
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>City</td>
<td>
<asp:TextBox ID="txtcity" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Email</td>
<td>
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnsave" runat="server" OnClick="btnsave_Click" Text="save" />
</td>
</tr>
<tr>
<td> </td>
<td>
</td>
</tr>
</table>
</div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</body>
</html>
DAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class Class1
{
}
public class ClsDataLayer
{
SqlConnection con = new SqlConnection("data source=ravi-PC;database='3tierexample';integrated security='true';");
public void InsertData(string _name,String _city,String _email)
{
SqlDataAdapter adp = new SqlDataAdapter("insert into Usermst values('"+_name+ "','" + _city + "','" + _email + "')",con);
DataTable dt = new DataTable();
adp.Fill(dt);
}
public object SelectData()
{
SqlDataAdapter adp = new SqlDataAdapter("select *from Usermst", con);
DataTable dt = new DataTable();
adp.Fill(dt);
return dt;
}
}
}
i will give you clear explanation
follow step by step
table
Presentation(User Interface)
Source Code for above design
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<div class="auto-style2">
<strong>3Tier Example</strong></div>
<table class="auto-style1">
<tr>
<td>Name</td>
<td>
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>City</td>
<td>
<asp:TextBox ID="txtcity" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>Email</td>
<td>
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:Button ID="btnsave" runat="server" OnClick="btnsave_Click" Text="save" />
</td>
</tr>
<tr>
<td> </td>
<td>
</td>
</tr>
</table>
</div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</body>
</html>
DAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
namespace DAL
{
public class Class1
{
}
public class ClsDataLayer
{
SqlConnection con = new SqlConnection("data source=ravi-PC;database='3tierexample';integrated security='true';");
public void InsertData(string _name,String _city,String _email)
{
SqlDataAdapter adp = new SqlDataAdapter("insert into Usermst values('"+_name+ "','" + _city + "','" + _email + "')",con);
DataTable dt = new DataTable();
adp.Fill(dt);
}
public object SelectData()
{
SqlDataAdapter adp = new SqlDataAdapter("select *from Usermst", con);
DataTable dt = new DataTable();
adp.Fill(dt);
return dt;
}
}
}
BLL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using BLL;
namespace BLL
{
public class Class1
{
}
public class CLSBussLayer
{
ClsDataLayer objDAL = new ClsDataLayer();
public void InsertUser(String _name,String _city,string _email)
{
objDAL.InsertData(_name, _city, _email);
}
public object SelectUser()
{
return objDAL.SelectData();
}
}
}
Code for Button_Click
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using DAL;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsave_Click(object sender, EventArgs e)
{
CLSBussLayer objBLL = new CLSBussLayer();
objBLL.InsertUser(txtname.Text, txtcity.Text, txtemail.Text);
GridView1.DataSource = objBLL.SelectUser();
GridView1.DataBind();
}
}
i will give you clear explanation
follow step by step
http://financialnew.checkseo.in/
ReplyDeletehttp://www.devmanuals.com/tutorials/ms/aspdotnet/dropdownlist.html
ReplyDeletehttp://www.aspdotnet-suresh.com/2014/06/best-login-page-design-in-html-css-with.html
ReplyDeletehttps://github.com/puikinsh/gentelella.git
ReplyDeletehttps://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_well&stacked=h
ReplyDeletefor calendar hide in asp.net js code
ReplyDelete=======================================
script type="text/javascript"
function hideCalender(sender, args) {
sender.hide();
document.getElementById('<%= btnShow.ClientID %>').focus();
}
/script
=====================
event: OnClientDateSelectionChanged="hideCalender"
http://www.codingfusion.com/Post/Textbox-autocomplete-using-jquery-in-asp-net
ReplyDeletehttp://www.c-sharpcorner.com/UploadFile/0c1bb2/create-excel-file-from-database-using-Asp-Net-C-Sharp/
ReplyDeletehttp://capyei.net
ReplyDeletehttp://www.c-sharpcorner.com/UploadFile/00a8b7/interview-questions-for-2-year-experience-in-sql-and-C-Sharp/
ReplyDeletehttp://www.c-sharpcorner.com/UploadFile/rohatash/get-out-parameter-from-a-stored-procedure-in-Asp-Net/
ReplyDeletehttp://www.devextras.com/decompiler/
ReplyDeletehttps://career.guru99.com/top-22-linq-interview-questions/
ReplyDelete