473,471 Members | 2,040 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Gridview: What happened to nTier architecture?

Hello

Im reading this article about the Gridview:

http://msdn.microsoft.com/msdnmag/is...4/08/GridView/

Whilst I realise that im not forced to use their methods I do find it
confusing that the article states that the code below is an example of the
"recommended data binding approach in ASP 2.0".
Why is placing DAL level code and connection strings on every page that uses
data from a data store now the "recommended approach"?

The idea seems completely stupid on every level.

Richard
<%@ Page theme="SmokeAndGlass" %>
<html>
<head runat="server" />
<body>
<form runat="server">
<asp:TextBox runat="server" ID="EmpID" Text="3" />
<asp:button runat="server" Text="Refresh" />

<asp:SqlDataSource runat="server" ID="MySource"
ConnectionString="SERVER=(local);DATABASE=northwin d;Integrated
Security=SSPI;"
DataSourceMode="DataSet"
SelectCommand="SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParameters>
<asp:ControlParameter Name="MinID" ControlId="EmpID"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>

<asp:GridView runat="server" ID="grid"
DataSourceId="MySource"
AutoGenerateColumns="true">
</asp:GridView>
</form>
</body>
</html>
Nov 30 '06 #1
3 1714
I think SqlDataSource has received a lot of criticism exactly for the
reasons you mention.

It seems to me that ObjectDataSource and/or building your own Data Source
are the way to go, in order to maintain a degree of isolation between the
presentation layer, business logic, and data access.

"Richard Coltrane" <rc@spamsux.comwrote in message
news:uM**************@TK2MSFTNGP03.phx.gbl...
Hello

Im reading this article about the Gridview:

http://msdn.microsoft.com/msdnmag/is...4/08/GridView/

Whilst I realise that im not forced to use their methods I do find it
confusing that the article states that the code below is an example of the
"recommended data binding approach in ASP 2.0".
Why is placing DAL level code and connection strings on every page that
uses data from a data store now the "recommended approach"?

The idea seems completely stupid on every level.

Richard
<%@ Page theme="SmokeAndGlass" %>
<html>
<head runat="server" />
<body>
<form runat="server">
<asp:TextBox runat="server" ID="EmpID" Text="3" />
<asp:button runat="server" Text="Refresh" />

<asp:SqlDataSource runat="server" ID="MySource"
ConnectionString="SERVER=(local);DATABASE=northwin d;Integrated
Security=SSPI;"
DataSourceMode="DataSet"
SelectCommand="SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParameters>
<asp:ControlParameter Name="MinID" ControlId="EmpID"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>

<asp:GridView runat="server" ID="grid"
DataSourceId="MySource"
AutoGenerateColumns="true">
</asp:GridView>
</form>
</body>
</html>


Nov 30 '06 #2
Richard,
I've never used this method myself and I've never found a need to. I
believe it is essentially an opinion on the topic as opposed to canon. Also,
keep in mind that this article was written a year before ASP.Net 2.0 came
out, so it's not entirely accurate as it was written with beta code, and
also the thinking at the time of the beta. Whenever I wonder about a best
approach, I typically refer to the various patterns and practices guides
that MS puts out. These tend to have the best concepts and tips for
architecting some of this stuff that most magazine articles.

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Richard Coltrane" <rc@spamsux.comwrote in message
news:uM**************@TK2MSFTNGP03.phx.gbl...
Hello

Im reading this article about the Gridview:

http://msdn.microsoft.com/msdnmag/is...4/08/GridView/

Whilst I realise that im not forced to use their methods I do find it
confusing that the article states that the code below is an example of the
"recommended data binding approach in ASP 2.0".
Why is placing DAL level code and connection strings on every page that
uses data from a data store now the "recommended approach"?

The idea seems completely stupid on every level.

Richard
<%@ Page theme="SmokeAndGlass" %>
<html>
<head runat="server" />
<body>
<form runat="server">
<asp:TextBox runat="server" ID="EmpID" Text="3" />
<asp:button runat="server" Text="Refresh" />

<asp:SqlDataSource runat="server" ID="MySource"
ConnectionString="SERVER=(local);DATABASE=northwin d;Integrated
Security=SSPI;"
DataSourceMode="DataSet"
SelectCommand="SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParameters>
<asp:ControlParameter Name="MinID" ControlId="EmpID"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>

<asp:GridView runat="server" ID="grid"
DataSourceId="MySource"
AutoGenerateColumns="true">
</asp:GridView>
</form>
</body>
</html>


Nov 30 '06 #3
For very small projects the SQL Datasource can save a lot of time. To solve
some of the shortcomings you mentioned I use this approach:

<asp:SqlDataSource ID="dsTips" runat="server" ConnectionString="<%$
ConnectionStrings:HRConnectionString %>" SelectCommand="jpTipsFetch"
SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Direction="ReturnValue" Name="RETURN_VALUE"
Type="Int32" />
<asp:FormParameter FormField="txtPKID" Name="PKID" Type="Int32"
/>
<asp:FormParameter FormField="cboDepartment"
Name="DepartmentName" Type="String" />
<asp:FormParameter DefaultValue="" FormField="cboEmployee"
Name="EmployeeName" Type="String" />
<asp:FormParameter DefaultValue="" FormField="cboSupervisor"
Name="SupervisorName" Type="String" />
</SelectParameters>
</asp:SqlDataSource>

After you get the hang of it it can save you a lot of time, but again, on
relatively small projects.
On Thu, 30 Nov 2006 16:54:39 +1300, "Richard Coltrane" <rc@spamsux.comwrote:
>Hello

Im reading this article about the Gridview:

http://msdn.microsoft.com/msdnmag/is...4/08/GridView/

Whilst I realise that im not forced to use their methods I do find it
confusing that the article states that the code below is an example of the
"recommended data binding approach in ASP 2.0".
Why is placing DAL level code and connection strings on every page that uses
data from a data store now the "recommended approach"?

The idea seems completely stupid on every level.

Richard
<%@ Page theme="SmokeAndGlass" %>
<html>
<head runat="server" />
<body>
<form runat="server">
<asp:TextBox runat="server" ID="EmpID" Text="3" />
<asp:button runat="server" Text="Refresh" />

<asp:SqlDataSource runat="server" ID="MySource"
ConnectionString="SERVER=(local);DATABASE=northwin d;Integrated
Security=SSPI;"
DataSourceMode="DataSet"
SelectCommand="SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParameters>
<asp:ControlParameter Name="MinID" ControlId="EmpID"
PropertyName="Text" />
</SelectParameters>
</asp:SqlDataSource>

<asp:GridView runat="server" ID="grid"
DataSourceId="MySource"
AutoGenerateColumns="true">
</asp:GridView>
</form>
</body>
</html>
Nov 30 '06 #4

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

Similar topics

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...
5
by: Ryan Ternier | last post by:
I know how this should be done in regards to nTier, but it seems a bit inneficient, and was wondering if there's a solution that I havn't thought of yet. (I'm switching this loop to For Each Row...
1
by: Dnx | last post by:
hi i'm a very beginner of visual studio .net 2003 and aspx/vb.net i have to create a project with an architecture ntier i understand the concept but in practical, i don't know where to begin... ...
2
by: Dabbler | last post by:
What's the best way to return to GridView after editing a detail record in a FormView so the GridView shows the page with the edited record on it? I'm using GridView with standard...
6
by: GaryDean | last post by:
I liked the DataGrid because I was familiar in walking through it to do custom filling and retrieval of data in cases where standard binding wouldn't do the job. I read somewhere that the object...
6
by: Kevin Attard | last post by:
I am using a GridView inside a UserControl which has a template column for deleting the rows. Before databinding the gridview i am attaching the RowCommand and RowDataBound event. I am using the...
4
by: Mike | last post by:
I'm having trouble getting a gridview to bind. I probably missing something completely obvious and would appreciate any help on offer. I'm passing parameters via querystring, and have created a...
5
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= | last post by:
I have a sub in vb.net that adds extra headers to a gridview and it works very well. however, i tried to translate it to c# and i'm getting the header inserting itself over the first datarows and...
0
by: Eraser | last post by:
Hi to all .NET guru guys... I have a problem in my delete button inside gridview. How to avoid postback on when i select cancel on confirmation message? But postback is okay on Ok confirmation....
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.