You will want to separate your application into separate "tiers," with
the ASP.NET web pages (the presentation) being in one tier, the business
objects being in the middle tier, and the database being in the bottom
tier.
That is, your ASP.NET Web pages will be fairly straightforward and
simply, relying on .NET Components to retrieve information in logical
chunks. For example, in the ASP.NET Forums, there are a number of
logical entities, such as a Post, a User, a Forum, a PostCollection, a
ForumCollection, and so on. The ASP.NET Web pages merely retrieve
information from the middle-tier in these terms, and then display the
information. For example, to display the title and author of a post on
a Web page, one would need to only do:
in code-behind:
----------------
Post p = Posts.GetPost(4);
lblTitle.Text = p.Title;
lblAuthor.Text = p.Username;
In HTML section:
-----------------
<asp:Label id="lblTitle" runat="server" />
<asp:Label id="lblAuthor" runat="server" />
The Posts object would have a method called GetPost() that takes in a
PostID and then calls a function called GetPostFromDatabase(PostID).
The GetPostsFromDatabase() method, actually, exists in a separate
middle-tier component, which makes the actual database call. This
tiered structure separates presentation, from business logic, from data
access.
To familiarize yourself, I would advise checking out the many FREE
source code projects the ASP.NET has made available. Go to:
http://asp.net/Default.aspx?tabindex=7&tabid=41
There you can find the code for the ASP.NET Forums, the IBuySpy Portal,
the IBuySpy Store, and so on. Examine the architecture for these
applications, and apply what you learn to your project. Furthermore,
you can check out the source code included with the "Starter Kits,"
which are available at:
http://asp.net/Default.aspx?tabindex=9&tabid=47