n-Tier/Layer with NULL and persistence

G

Guest

I'm building an n-Layer application that may be segmented into n-Tiers. For
the user interface I'm implementing an MVC architecture.

Since I can't access the page class directly from another class, is there a
way to put items in the viewstate without writing a function in the aspx page?

i.e. I can do the following
Public MustInherit Class EditViewBase
Inherits System.Web.UI.Page
Public MustOverride Property Persist(ByVal key As String) As Object
End Class
Partial Class Edit
Inherits EditViewBase

Public Overrides Property Persist(ByVal key As String) As Object
Get
Return ViewState(key)
End Get
Set(ByVal value As Object)
ViewState(key) = value
End Set
End Property
End Class

But I have to put that on every page. Is there a way to simplify or
abstract this?

Question 2 is, how do people in general handle null values in a model from
the database to the screen and back? I could implement everything as a
string and use an empty string to reflect a null, but most examples of model
classes I've seen do something like the following:
Class Model
Private _age As Integer
Public Property Age() As Integer
Get
Return _age
End Get
Set(ByVal value As Integer)
_age = value
End Set
End Property
End Class

But I don't see a clean way of tracking if the Property is NULL or undefined.

Thanks for any insight.
 
G

Guest

nm on the ViewState. Apparently I do have access to it. Yay. Question 2
stands though. How do people in general handle NULL values from the database
to the screen and back in a Model?
 
P

Patrick.O.Ige

Larry if what you need to check the NULL values in he DB use
DBNull.value
Patrick
 
G

Guest

My question was a little broader. I'm interested in how I put a null from a
database into an Integer in VB and when it gets to the screen as an entry
field it's an empty field (and in general wherever I use it I know that it
hasn't been defined yet as opposed to say 0). And then if I leave the field
empty how do I assign it back to an Integer and still know when I get to the
database that I need to stick a DBNull.Value into the field?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top