Recent Posts

Wednesday, November 19, 2008

Learn how to develop a three tier web application using ( with source code

This article focuses on explaining how to code a three tier web application visual basic. Here I will be explaining how you can bind an object to the data grid and display the data from the database just by adding the references to the business logic and data access dlls.

Ok first open a web project in visual studio 2005 and in Default.aspx add a Gridview and name it grdStudents

Now you need to add the references to the business tier dlls and data tier dlls.

Add the following references to the project:


How to get these dlls is explained in detail in How to develop a three tier .net application using visual basic with source Code.

Now after adding the references to the project
copy and paste the following code in the code behind page (Default.aspx.vb) of your Default.aspx

Partial Class _Default
Inherits System.Web.UI.Page
Private _students As ThreeTierVB.Info.StudentInfo()

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub

Private Sub BindGrid()
Dim clsS As New ThreeTierVB.BusinessLogic.StudentsBLL
_students = clsS.GetStudentByClass(1)

With grdStudents

.DataSource = _students
.Columns.Item(0).Visible = False
.Columns.Item(3).Visible = False

End With
End Sub
End Class

In the above code we have declared the collection of students and bind the collection of the students to the gridview grdStudents.

Now run the application and you can see the grid filled with data.

Now lets make the grid a bit preety by adding the following code in your default.aspx page:

just replace the grid view code with the following:

Now run the application and see the new look of the grid.

Thus now you can code any three tier web or desktop applicaion in .net.

Related Posts by Categories

No comments:

Post a Comment