473,803 Members | 4,591 Online
Bytes | Software Development & Data Engineering Community
+ 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
"recommende d 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 "recommende d approach"?

The idea seems completely stupid on every level.

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

<asp:SqlDataSou rce runat="server" ID="MySource"
ConnectionStrin g="SERVER=(loca l);DATABASE=nor thwind;Integrat ed
Security=SSPI;"
DataSourceMode= "DataSet"
SelectCommand=" SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParamete rs>
<asp:ControlPar ameter Name="MinID" ControlId="EmpI D"
PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>

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

It seems to me that ObjectDataSourc e 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.com wrote in message
news:uM******** ******@TK2MSFTN GP03.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
"recommende d 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 "recommende d approach"?

The idea seems completely stupid on every level.

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

<asp:SqlDataSou rce runat="server" ID="MySource"
ConnectionStrin g="SERVER=(loca l);DATABASE=nor thwind;Integrat ed
Security=SSPI;"
DataSourceMode= "DataSet"
SelectCommand=" SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParamete rs>
<asp:ControlPar ameter Name="MinID" ControlId="EmpI D"
PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>

<asp:GridView runat="server" ID="grid"
DataSourceId="M ySource"
AutoGenerateCol umns="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.com wrote in message
news:uM******** ******@TK2MSFTN GP03.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
"recommende d 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 "recommende d approach"?

The idea seems completely stupid on every level.

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

<asp:SqlDataSou rce runat="server" ID="MySource"
ConnectionStrin g="SERVER=(loca l);DATABASE=nor thwind;Integrat ed
Security=SSPI;"
DataSourceMode= "DataSet"
SelectCommand=" SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParamete rs>
<asp:ControlPar ameter Name="MinID" ControlId="EmpI D"
PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>

<asp:GridView runat="server" ID="grid"
DataSourceId="M ySource"
AutoGenerateCol umns="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:SqlDataSou rce ID="dsTips" runat="server" ConnectionStrin g="<%$
ConnectionStrin gs:HRConnection String %>" SelectCommand=" jpTipsFetch"
SelectCommandTy pe="StoredProce dure">
<SelectParamete rs>
<asp:Paramete r Direction="Retu rnValue" Name="RETURN_VA LUE"
Type="Int32" />
<asp:FormParame ter FormField="txtP KID" Name="PKID" Type="Int32"
/>
<asp:FormParame ter FormField="cboD epartment"
Name="Departmen tName" Type="String" />
<asp:FormParame ter DefaultValue="" FormField="cboE mployee"
Name="EmployeeN ame" Type="String" />
<asp:FormParame ter DefaultValue="" FormField="cboS upervisor"
Name="Superviso rName" Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>

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.com wrote:
>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
"recommende d 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 "recommende d approach"?

The idea seems completely stupid on every level.

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

<asp:SqlDataSou rce runat="server" ID="MySource"
ConnectionStrin g="SERVER=(loca l);DATABASE=nor thwind;Integrat ed
Security=SSPI;"
DataSourceMode= "DataSet"
SelectCommand=" SELECT firstname, lastname FROM employees WHERE
employeeid @MinID">
<SelectParamete rs>
<asp:ControlPar ameter Name="MinID" ControlId="EmpI D"
PropertyName="T ext" />
</SelectParameter s>
</asp:SqlDataSour ce>

<asp:GridView runat="server" ID="grid"
DataSourceId="M ySource"
AutoGenerateCol umns="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
5065
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 Logic Layer (BLL) and User Interface Layer (UIL). The problem I found with this was circular referencing...
5
1182
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 as DataRow in.... to kill the one int that's not needed.) For intCount1 = 0 To objData.DataSet.Tables("tblSecondaryNumbers").Rows.Count - 1 rowTemp = objData.DataSet.Tables("tblSecondaryNumbers").Rows(intCount1)
1
1029
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... please help me thank you
2
3325
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 ObjectDataSource, no custom paging. Thanks for any tips on this.
6
2327
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 model is the same for the datagrid and the gridview. But as I begin to try to manually load a gridview I notice that there is no such thing as a GridViewItem as there was a DataGridItem. So, it's not the same. Are there any articles or...
6
28178
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 RowDataBound event to set the commandargument of the delete button. The event is being fired and works fine. When I press the delete button, the RowCommand event is not firing! and neither is the RowDeleting (the button's commandName is...
4
2613
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 stored proc as follows: qGetSearchResults: SELECT Adverts.AdvertID,
5
1974
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 inserting blank rows at the bottom. i can post the code if necessary for the C# but it basicly mirrors the vb.net -- (i''ll be asking a lot of these, but I find C# totally way cooler than vb
0
2825
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. What happened is if I select cancel on my confirmation button, it executes the griedview postback which i assigned in my code behind. Please see my codes below... Code beind: protected void gvDefectCatalog_RowDataBound(object sender,...
0
9703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10548
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10295
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.