Click here to Skip to main content
15,896,111 members
Articles / Web Development / ASP.NET

Designing and implementing a versatile data access tier for an ASP.NET application

Rate me:
Please Sign up or sign in to vote.
4.63/5 (45 votes)
3 Feb 200328 min read 384.9K   3.8K   242  
In this article, we will drill down deeper in to the design of a n-tier architecture and our focus will be on the data access tier (DAT)
<%@ Page language="c#" Codebehind="SerchCustomOrders.aspx.cs" AutoEventWireup="false" Inherits="DAPrototype.SerchCustomOrders" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>SerchCustomOrders</title>
		<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	</HEAD>
	<body bgColor="#ffffcc" MS_POSITIONING="GridLayout">
		<form id="SerchCustomOrders" method="post" runat="server">
			<asp:label id="lbHead" style="Z-INDEX: 103; LEFT: 177px; POSITION: absolute; TOP: 19px" runat="server" Font-Size="Large" Font-Bold="True" Width="132px" Height="33px">DAPrototype</asp:label>
			<TABLE id="tbQuery" style="Z-INDEX: 101; LEFT: 37px; WIDTH: 224px; POSITION: absolute; TOP: 74px; HEIGHT: 38px" cellSpacing="0" cellPadding="0" width="224" border="0">
				<TR>
					<TD style="WIDTH: 114px"><asp:label id="lbCustomerID" runat="server" Font-Size="Small" Font-Bold="True" Width="95px">Customer ID</asp:label></TD>
					<TD><asp:textbox id="tbCustomerID" runat="server"></asp:textbox></TD>
					<TD><asp:button id="btnSearch" runat="server" Width="82px" Text="Search"></asp:button></TD>
				</TR>
			</TABLE>
			<asp:datalist id="dlCustomer" style="Z-INDEX: 102; LEFT: 30px; POSITION: absolute; TOP: 160px" runat="server" Width="256px" BorderColor="#DEBA84" BackColor="#DEBA84" CellPadding="3" BorderWidth="1px" BorderStyle="None" CellSpacing="2" Height="0" GridLines="Both" HorizontalAlign="Center" ShowFooter="False">
				<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></SelectedItemStyle>
				<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
				<ItemTemplate>
					<B>CustomerID:</B>
					<asp:Label id=lbCusID runat="server" Width="76px" Text='<%#DataBinder.Eval(Container.DataItem,"CustomerID")%>'>
					</asp:Label><BR>
					<B>CompanyName:</B>
					<asp:Label id=lbCompanyName runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"CompanyName")%>'>
					</asp:Label><BR>
					<B>Address:</B>
					<asp:Label id=lbAddress runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Address")%>'>
					</asp:Label>
					<br>
					<b>City:</b>
					<asp:Label id="lbCity" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"city")%>'>
					</asp:Label><BR>
					<asp:Button id="btnShow" runat="server" Width="86px" Text=" Orders" CommandName="ShowOrder"></asp:Button>
				</ItemTemplate>
				<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
				<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#A55129"></HeaderStyle>
			</asp:datalist>
			<TABLE id="tbDataGrid" style="Z-INDEX: 104; LEFT: 368px; WIDTH: 167px; POSITION: absolute; TOP: 154px; HEIGHT: 141px" cellSpacing="0" cellPadding="0" width="167" border="0">
				<TR>
					<TD style="HEIGHT: 5px">
						<asp:Label id="lbGridHead" runat="server" Font-Size="Medium" Font-Bold="True" Width="188px" Visible="False">Label</asp:Label>
					</TD>
				</TR>
				<TR>
					<TD>
						<asp:datagrid id="dgOrder" runat="server" AutoGenerateColumns="False" BorderColor="#DEBA84" BackColor="#DEBA84" CellPadding="3" BorderWidth="1px" BorderStyle="None" CellSpacing="2" Width="220px" AllowSorting="True">
							<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#738A9C"></SelectedItemStyle>
							<ItemStyle ForeColor="#8C4510" BackColor="#FFF7E7"></ItemStyle>
							<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#A55129"></HeaderStyle>
							<FooterStyle ForeColor="#8C4510" BackColor="#F7DFB5"></FooterStyle>
							<Columns>
								<asp:BoundColumn DataField="OrderID" SortExpression="OrderID  DESC" ReadOnly="True" HeaderText="OrderID"></asp:BoundColumn>
								<asp:TemplateColumn SortExpression="OrderDate ASC" HeaderText="OrderDate">
									<ItemTemplate>
										<asp:Label id="lbDate" Text = '<%#DateTransform(DataBinder.Eval(Container.DataItem,"OrderDate"))%>' runat="server" Width="111px">
										</asp:Label>
									</ItemTemplate>
								</asp:TemplateColumn>
								<asp:ButtonColumn Text="Details" CommandName="OrderDetail"></asp:ButtonColumn>
							</Columns>
							<PagerStyle HorizontalAlign="Center" ForeColor="#8C4510" Mode="NumericPages"></PagerStyle>
						</asp:datagrid>
					</TD>
				</TR>
			</TABLE>
		</form>
	</body>
</HTML>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Switzerland Switzerland
Paul Abraham is a software developer who designs and develops multi-shop systems.

He has received his M.Sc in Mathematics and Computer Science from the FernUniversität Hagen(http://www.fernuni-hagen.de Germany) and his main interests are neural networks and bayesian statistics He lives in Rosenheim (South Germany http://www.rosenheim.de). You can reach him at admin@paul-abraham.com.

Comments and Discussions