Last post Dec 28, 2011 06:43 PM by nmaddock123
Dec 22, 2011 09:08 PM|nmaddock123|LINK
in a 3 tier web application, how can i popluate textboxes with text on a webform from the business access layer? do i need to search for the control by name? that seems a rough way to do it.
thanks in advance
Dec 23, 2011 04:43 AM|premchand_p_l|LINK
I think the best way to populate the web form text box should not be from the business layer. Create a DTO object, populate the DTO object and use that DTO object to pupulate the text box.
You cannot access the text box control of the UI from the BAL.
Dec 23, 2011 05:58 AM|nirmal.bond|LINK
You can't populate it on BAl. You can create its properties their and assisgn those properties to you textboxes at your presentation layer.
Dec 26, 2011 11:35 PM|varunthedon|LINK
Populating textboxes from business layer is not possible.
Instead, pass it to the presentation layer and then populate it.
Best practice is as nirmal sugessted, create properties to the textboxes and pass it on to the presentation layer.
Dec 27, 2011 01:45 AM|atconway|LINK
There are several ways you can accomplish this, but (2) that I recommend.
1. Create custom business entities or business objects in your BLL. These custom classes will have properties on them which ultimately will be bound to different types of controls in the UI. The ide is that the UI layer calls the business logic layer to
get back a List(Of <T>), where <T> is your custom class, and then in some form is used as the datasource for your UI control.
2. The 2nd method allows a better abstraction and is less tightly coupled than the example above but is a bit more work. The idea is to create 'Views' or special classes specific for transforming business or domain objects into objects for binding and communicating
to the UI. The advantage of creating these Views is they are typically UI type agnostic which allows for greater re-use if the application needed to be ported to another application type (i.e. webforms to smart client, etc.). The MVP (Model-View-Presenter)
or DDD (Domain Driven Design) are a good variation of the 3-tier architecture that would encompass using views.
#2 above might have been more food for thought, and #1 probably makes more sense, so below is a brief example.
Public Class Employee
Public Property FirstName As String
Public Property LastName As String
Public Property ID As Integer
Public Function GetAll() As List(Of Employee)
'Code here to call DAL,Repository, etc and get all employees
Public Sub BindEmployees()
'Some UI method to populate a GridView using a List(Of Employee) from the BLL
Dim Employees As New List(Of BLL.Employee)
Using Emp As New Employee()
Employees = Emp.GetAll()
'Bind the GridView to the list
Me.GridView1.DataSource = Employees
Of course the sample code is quite rudimentary and many other design principals and patterns have been omitted, but it should show you how the (2) layers interact. Hope this helps!
Dec 28, 2011 06:43 PM|nmaddock123|LINK
thanks for your help