3-Tier architecture is a very well know buzz word in the world of software development whether it web based or desktop based. Below is the code for BAL (Your can overwrite your default written code for the class file by pasting this code). You can also navigate to another page your created (list.aspx) and try updating, deleting records.In this article I am going to show how to design a web application based on 3-tier architecture. Code for Business Access Layer using System; using System. By using 3-Tier architecture in your project you can achive 1.Now our application is ready to use, press F5 or other as you know, then enter the some values to Text Box and press the "Save" button.Now after clicking on the "Save" button, the hidden field value takes the value "Insert" and es it to the Stored Procedure as the action and because of this the Stored Procedure will execute a particular type of block.Suppose I have one web page in which I need a to insert, view, update and delete records.To do that, instead of creating four Stored Procedures to perform these tasks I will create a single Stored Procedure to satisfy my requirements and I will access it in code behind depending on the action performed by the end user on a button click.Basically I have tried to make the normal Add (Insert), Edit, Update and delete functions in ASP.Net Grid View simple and also combining the powers of ASP.
The comments in the Stored Procedure above clearly explain which block is used for which purpose, so I have briefly explained it again.I have used the @Action variable and assigned the string to them and according to the parameter ed to the Stored Procedure the specific block will be executed because I have kept these blocks or conditions in nested if else if conditional statements."The most important thing is that I have assigned null to each variable to avoid the effect on the parameter ed to the Stored Procedure because we are ing a different number of parameters but not the same number of parameters to the Stored Procedure to perform these tasks." In the sample code above I have used the two string queries for giving the Stored Procedure name and the constr for storing the connection from the web.config file and another thing is that I have used a hidden field by which I am ing the action values that are required to our Stored Procedure. ID" Dim s Constr As String = Configuration Manager. Connection String Using conn As Sql Connection = New Sql Connection(s Constr) Using comm As Sql Command = New Sql Command(SQL, conn) conn. Data Bind() End Sub protected void Grid View1_Row Data Bound(object sender, Grid View Row Event Args e) protected void Grid View1_Row Updating(object sender, Grid View Update Event Args e) protected void Grid View1_Row Editing(object sender, Grid View Edit Event Args e) protected void Grid View1_Row Canceling Edit(object sender, Grid View Cancel Edit Event Args e) 0 Then Dim chk Brand As Check Box List = Direct Cast(e. Find Control("Check Box List1"), Check Box List) Dim dt As Data Table Dim SQL As [String] = "SELECT * FROM Brand" Dim s Constr As String = Configuration Manager. Connection String Using conn As New Sql Connection(s Constr) Using comm As New Sql Command(SQL, conn) conn. Open() ' Dim cmd As New Sql Command(s Update SQL, conn) ' cmd. Add With Value("@Brand ID", Direct Cast(Grid View1. The another problem is after populating how to display or show current database value by default in Check Box List as a Selected Value in edit mode.