Hi,

I have read many post obout n-layer programming, but still have found no good example or reply on some fundamental issues that I have.

I use 3 tier (Dal, BLL, Pll) and for some gridview I want to present the following in one column:

the fields period 1, period 2, period 3, period 4 and period 5 (all boolean) but only if the value is true. I retrieve all data from a (ms Sql) database. The following code I added to the aspx-file, to create a string that will give me only the periods that are true (it works):

Public Function perioden(ByVal rst As SVS.POsRow) As String

Dim p As String = ":"

If rst.per1 Then p += "1"

If rst.per2 Then p += " 2"

If rst.per3 Then p += " 3"

If rst.per4 Then p += " 4"

If rst.per5 Then p += " 5"

If p.Length > 3 Then

p = p.Replace(" ", " - ")

End If

Return p

End Function

So the result can be: ":1-3-4"

In my gridview I added a label (in itemtemplate ) with the following code:

<asp:Label ID="label_p" runat="server" Text="<%# perioden(ctype(ctype(container.dataitem, system.data.datarowview).row, svs.posrow)) %>">


This also works fine. But, now I want to call this function 'perioden' not only in this aspx-file but in my whole webapplication. I tried to create a class with this public function , I get an error that the function isn't found.

So, do I put all this kind of presentation layout code in the aspxfiles (PLL) or cal I somehow more this to a class that can be accessed from all pages?

Hi Vuyiswa Maseko,

Yes, I have seen your code in my search for answers to my issue. But I am not intelligent or experienced enough to fully understand how your tutorials is helping my issue. I am missing the link and need to be helped by pointing me (more) in the right direction. Thanks

I have Written Articles on that Subject years ago look at this links

http://www.codeproject.com/KB/cs/NTier.aspx

http://www.codeproject.com/KB/cs/NTier.aspx

http://www.codeproject.com/KB/cs/N-Tier22.aspx

http://www.codeproject.com/KB/vb/N-Tier_Application_VB.aspx

http://www.codeproject.com/KB/cs/N-Tier22.aspx

Looking at your Problem. In my article i showed an Example. If you create a Class(BLL) or DAL you must add references for the class so that your application can use it. The BLL must never access the Database or execute the Database directly. What you need to do is to add a Reference of our DAL in your BLL and add a Reference of your BLL in your PL(Presentation Layer) your web app, and then you can create an object of a Class and be able to call the functions declared as public in that Method.

Thank you for your reply. So the answer lies in adding a reference of my BLL in my PL , create object of class and call the function. In your example I have seen this working, but I can't get it to work for the function in my BLL won't accept a row (svs.POsRow). What am I doing wrong?

is your Function a Public function ? if you created a function , you need to build your BLL and if the PL does not see the function, remove the refence to the Bll and add it again.

is your Function a Public function ? if you created a function , you need to build your BLL and if the PL does not see the function, remove the refence to the Bll and add it again.

HI,
The BLL sees the function, the question I am now is how I can send a gridview row as parameter to the (shared) function in de BLL? In the PLL, I call the rowdatabound e.row.dataitem, but I have no idea how I can reference this in the BLL class

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.