473,396 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

n-Tier/Layer with NULL and persistence

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.
Apr 8 '06 #1
3 1220
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?

"Larry Charlton" wrote:
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.

Apr 8 '06 #2
Larry if what you need to check the NULL values in he DB use
DBNull.value
Patrick

"Larry Charlton" <La***********@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
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?

"Larry Charlton" wrote:
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.

Apr 9 '06 #3
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?

"Patrick.O.Ige" wrote:
Larry if what you need to check the NULL values in he DB use
DBNull.value
Patrick

"Larry Charlton" <La***********@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
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?

"Larry Charlton" wrote:
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.


Apr 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: tstephan | last post by:
In the past we have used the classic nTier design with COM+, SQL Server and MFC. We are currently working on a new project with an opportunity to use .NET, ADO.NET, etc. One of the areas where I...
2
by: Matheus Eduardo | last post by:
Hi everyone, I'm looking for an persistence layer for C# and .NET Framework, like Sun JDO or Castor JDO for Java. Does anyone could help me? Greetings in advance. Matheus Eduardo
25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
9
by: Hasan O. Zavalsiz | last post by:
Hi , i am trying to figure out which approach is better to use . let me explain the scenario. i am using the "Nortwind" database . in this database i have "Customers " table .The following is the...
2
by: dkode | last post by:
Hello, I am laying out the architecture for a very large website that will scale to a very large degree. I have a couple of questions before I attempt to go and implement a Broker/Persistence...
16
by: Dotnet | last post by:
I want to so the "right thing". But first, I have a confession to make. I've built a few ASP.NET sites now (Version 2.0), and they all work fine. However, I have (and here's the confession) used...
0
by: acnx | last post by:
I have an ntier application. I am trying to determine what is the best practice for handing errors in a datagrid. My datagrids are able to add, update and delete data. I am using a...
0
myusernotyours
by: myusernotyours | last post by:
Hi all, Am trying to create a Java Desktop App that uses Java Persistence in Netbeans. The database is MS Access but I tried with Mysql and got the same error. When I run the app( Create the...
3
Claus Mygind
by: Claus Mygind | last post by:
I am adding autosuggest to my code. My problem is the autosuggest response appears behind my other <div>'s and when I try to assign a higher z-index I get a "invalid assignment left-hand side"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.