|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ASPNET2 Radically Changed from v1.1The typical pattern for a data-driven aspx page in v1.1 was data connection -> data adapter -> dataset -> bound controls. V2 (at least by default) doesn't include data connections, data adapters or datasets in the toolbox when building an aspx page. Nor can I find where the DataView component went to. Everything now seems to rely on the DataSource controls. Some examples (to which I would appreciate responses on "here's how it's done in v2"): 1) If I want to present two different views of the same data -- where I would previously declare two separate DataView components onto the design surface of a page and then bind controls to them -- must I create two different data sources? This sounds like I'm buying into multiple requests against the database for essentially the same data. 2) One pattern I used a lot in v1.1 was to define a current record object (for either the form or a row in a databound control), and then use it to return values to display. For example, suppose a record in the database had two fields, Title and DateChanged. I would concatenate these two fields in a protected method called from within, say, a DataRepeater: protected string TitleAndDate( DataRowView curDRV ) { some_data_set.row_type strongly_typed_row = (some_data_set.row_type) curDRV.Row; return strongly_typed_row.Title + " (" + strongly_typed_row.DateChanged.ToShortDateString() + ")"; } And yes, I know I could do this through databinding expresssions, but frankly they were a pain in the butt to configure; this way may have been less efficient, but it was clearer. At least to me :). But in v2 the Datasource control doesn't seem to return a strongly-typed collection of objects. In fact, there doesn't seem to be any "knowledge" of the underlying database schema exposed in the return value of, say, its Select() statement (clearly the schema is contained in the Datasource control, but it seems hidden...or at least I haven't been able to find it). How do I get access to strongly-typed values from a Datasource control so I can do things like I was used to doing in v1.1? Frankly...so far I am deeply underwhelmed by the supposed productivity improvements in v2. They may be there -- okay, they are almost certainly there -- but the overall approach to building websites is so radically different in ASPNET2 that I'm going to suffer a major productivity hit just figuring out how to get started. It also seems like the v2 framework is more restrictive, in the sense that it lets you do things simply -- provided you do them in a particular way. I understand that's the nature of a framework, but good frameworks strike a balance between restrictions and flexibility. Maybe it's just the radical change from v1.1 to v2, but so far all I see is a lot more restrictions, and a lot less access to the plumbing. - Mark Hi Mark,
Welcome. :-) I've also seen your another thread in this group about the global.asax's component desiging question, I've posted there. As for the questions about the new ASP.NET 2.0 data accessing model, here are some of my understanding: 1. Yes, the ASP.NET 2.0 no longer used the original component based Data Accessing model, it use the DataSource control to replace the ( DataSet+DataAdapter+ Connection ), thus, we can avoid many autogenerated code in code behind, but use the statically defined control template in aspx page.... Using the configuration wizard and smartTag in VS2005 for generating or configuration datasource control are quite easy.... The DataSource controls can let us define some selecting or filtering expression and parameters which help customizing the select result...... these parameters can be bound to many sources (querystring, form, Control, ......) 2. For the using TypedDataSet and typed DataRow object, there still exists such model, and this is even enhanced by the new TypedDataSet + TableAdapter model. Through the VS 2005 IDE, we can easily create a TypedDataSet from DataBase and together with a TableAdapter which encapsulate all the code wo used to configure through DataAdaper. (You can see my reply in your another thread on this...). Thus, we can still directly use TableAdapter to get a TypedDataSet or a TypedDataTable and use that to bind the Databound controls (GridView, DataList, DetailsView......). SqlDataSource control is mainly used for encapsulating the (unTypedDataset + DataAdapter ) data accessing model, in the asp.net 2.0, we can also find the ObjectDataSource control, this control is used for associate the ASP.NET databound controls with our buisness or dataaccess components, and one typical scenario for using ObjectDataSource is just configure the TableAdapter (we mentioned above) in the ObjectDatasource and bind the ObjectDataSource control to the databound controls ......., if you feel the autogenerated methods are not sufficient, we can add our own methods into the generated class or event define our own dataaccessing Class, and configure it in ObjectDataSource.... Also, when adding a Datasource control onto an ASP.NET 2.0 page, it's not necessary to bind them to a databound control, we can also programmatically use them to get a Data record set by calling their Select method. Some pre/post processing events like Seelcting/Selected, updating/updated...... also help us do some customization on the data accessing when using datasource control.... Here are some related tutorial or msdn reference on ASP.NET 2.0's databinding and using Datasource control, TableAdapter: #Binding to a Visual Studio DataSet http://www.asp.net/QuickStart/aspnet/doc/data/objects.aspx#dataset #ObjectDataSource Control Overview http://msdn2.microsoft.com/en-us/library/9a4kyhcx.aspx #TableAdapter Overview http://msdn2.microsoft.com/en-us/library/bz9tthwx.aspx Hope helps. Thanks, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | NNTP-Posting-Date: Fri, 23 Dec 2005 01:56:19 -0600 sv3-2vkvCMoImkATxChi91fwCMyfSBAFekgHAyqH20qe1gaPyN5XcglRh8+nkyFdA5Mmn33cijYq| From: Mark Olbert <ChairmanMAO@newsgroups.nospam> | Newsgroups: microsoft.public.dotnet.framework.aspnet | Subject: ASPNET2 Radically Changed from v1.1 | Date: Thu, 22 Dec 2005 23:56:18 -0800 | Organization: Olbert & McHugh, LLC | Reply-To: m***@arcabama.com | Message-ID: <e6anq15m1durd4pitfm9i78rm6g39nk***@4ax.com> | X-Newsreader: Forte Agent 3.1/32.783 | MIME-Version: 1.0 | Content-Type: text/plain; charset=us-ascii | Content-Transfer-Encoding: 7bit | Lines: 42 | X-Trace: pdR2DYe!lkh4NF4DAyyAsJEa66Ev0gO/0ygDEzQxoF8qBIVTFvOLLJgBfeo5Pt7e76a09Fk46mpw zg== | X-Complaints-To: ab***@giganews.com TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli| X-DMCA-Notifications: http://www.giganews.com/info/dmca.html | X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers | X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly | X-Postfilter: 1.3.32 | Path: ne.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.gigan ews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail | Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.aspnet:366737| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet connection -> data adapter -> dataset -> bound controls. V2 (at| | I'm starting to play around with VS2005 and ASP.NET 2 and have some questions. | | The typical pattern for a data-driven aspx page in v1.1 was data | least by default) doesn't include data connections, data adapters or datasets in the toolbox when building an aspx page. Nor can I| find where the DataView component went to. Everything now seems to rely on the DataSource controls.| done in v2"):| Some examples (to which I would appreciate responses on "here's how it's | would previously declare two separate DataView components| 1) If I want to present two different views of the same data -- where I | onto the design surface of a page and then bind controls to them -- must I create two different data sources? This sounds like I'm| buying into multiple requests against the database for essentially the (for either the form or a row in a databound control), andsame data. | | 2) One pattern I used a lot in v1.1 was to define a current record object | then use it to return values to display. For example, suppose a record in the database had two fields, Title and DateChanged. I| would concatenate these two fields in a protected method called from within, say, a DataRepeater:| strongly_typed_row.DateChanged.ToShortDateString() + ")";| protected string TitleAndDate( DataRowView curDRV ) | { | some_data_set.row_type strongly_typed_row = (some_data_set.row_type) curDRV.Row; | | return strongly_typed_row.Title + " (" + | } frankly they were a pain in the butt to configure; this way| | And yes, I know I could do this through databinding expresssions, but | may have been less efficient, but it was clearer. At least to me :). collection of objects. In fact, there doesn't seem to be| | But in v2 the Datasource control doesn't seem to return a strongly-typed | any "knowledge" of the underlying database schema exposed in the return value of, say, its Select() statement (clearly the schema is| contained in the Datasource control, but it seems hidden...or at least I haven't been able to find it).| I can do things like I was used to doing in v1.1?| How do I get access to strongly-typed values from a Datasource control so | improvements in v2. They may be there -- okay, they are| Frankly...so far I am deeply underwhelmed by the supposed productivity | almost certainly there -- but the overall approach to building websites is so radically different in ASPNET2 that I'm going to| suffer a major productivity hit just figuring out how to get started. that it lets you do things simply -- provided you do them in a| | It also seems like the v2 framework is more restrictive, in the sense | particular way. I understand that's the nature of a framework, but good frameworks strike a balance between restrictions and| flexibility. Maybe it's just the radical change from v1.1 to v2, but so far all I see is a lot more restrictions, and a lot lessShow quoteHide quote | access to the plumbing. | | - Mark | SqlDataSource should crawl under a rock and die :) It's a fine
implementation if the documentation properly explains that by using it you absolutely destroy any chance of having a properly layered system. In some cases that's acceptable (like a prototype, or your mom's webpage), in all others the benefits are probably far outweighed by the drawbacks. It's a point far too often left unsaid. Karl -- Show quoteHide quoteMY ASP.Net tutorials http://www.openmymind.net/ http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX! "Steven Cheng[MSFT]" <stch***@online.microsoft.com> wrote in message news:rVbr0z7BGHA.1236@TK2MSFTNGXA02.phx.gbl... > Hi Mark, > > Welcome. :-) > I've also seen your another thread in this group about the global.asax's > component desiging question, I've posted there. > As for the questions about the new ASP.NET 2.0 data accessing model, here > are some of my understanding: > > 1. Yes, the ASP.NET 2.0 no longer used the original component based Data > Accessing model, it use the DataSource control to replace the ( > DataSet+DataAdapter+ Connection ), thus, we can avoid many autogenerated > code in code behind, but use the statically defined control template in > aspx page.... Using the configuration wizard and smartTag in VS2005 for > generating or configuration datasource control are quite easy.... The > DataSource controls can let us define some selecting or filtering > expression and parameters which help customizing the select result...... > these parameters can be bound to many sources (querystring, form, > Control, > .....) > > 2. For the using TypedDataSet and typed DataRow object, there still exists > such model, and this is even enhanced by the new TypedDataSet + > TableAdapter model. Through the VS 2005 IDE, we can easily create a > TypedDataSet from DataBase and together with a TableAdapter which > encapsulate all the code wo used to configure through DataAdaper. (You can > see my reply in your another thread on this...). Thus, we can still > directly use TableAdapter to get a TypedDataSet or a TypedDataTable and > use > that to bind the Databound controls (GridView, DataList, > DetailsView......). > > SqlDataSource control is mainly used for encapsulating the (unTypedDataset > + DataAdapter ) data accessing model, in the asp.net 2.0, we can also > find > the ObjectDataSource control, this control is used for associate the > ASP.NET databound controls with our buisness or dataaccess components, > and > one typical scenario for using ObjectDataSource is just configure the > TableAdapter (we mentioned above) in the ObjectDatasource and bind the > ObjectDataSource control to the databound controls ......., if you feel > the > autogenerated methods are not sufficient, we can add our own methods into > the generated class or event define our own dataaccessing Class, and > configure it in ObjectDataSource.... > > Also, when adding a Datasource control onto an ASP.NET 2.0 page, it's not > necessary to bind them to a databound control, we can also > programmatically > use them to get a Data record set by calling their Select method. Some > pre/post processing events like Seelcting/Selected, > updating/updated...... > also help us do some customization on the data accessing when using > datasource control.... > > Here are some related tutorial or msdn reference on ASP.NET 2.0's > databinding and using Datasource control, TableAdapter: > > #Binding to a Visual Studio DataSet > http://www.asp.net/QuickStart/aspnet/doc/data/objects.aspx#dataset > > #ObjectDataSource Control Overview > http://msdn2.microsoft.com/en-us/library/9a4kyhcx.aspx > > #TableAdapter Overview > http://msdn2.microsoft.com/en-us/library/bz9tthwx.aspx > > Hope helps. Thanks, > > Steven Cheng > Microsoft Online Support > > Get Secure! www.microsoft.com/security > (This posting is provided "AS IS", with no warranties, and confers no > rights.) > > > > > > > > > -------------------- > | NNTP-Posting-Date: Fri, 23 Dec 2005 01:56:19 -0600 > | From: Mark Olbert <ChairmanMAO@newsgroups.nospam> > | Newsgroups: microsoft.public.dotnet.framework.aspnet > | Subject: ASPNET2 Radically Changed from v1.1 > | Date: Thu, 22 Dec 2005 23:56:18 -0800 > | Organization: Olbert & McHugh, LLC > | Reply-To: m***@arcabama.com > | Message-ID: <e6anq15m1durd4pitfm9i78rm6g39nk***@4ax.com> > | X-Newsreader: Forte Agent 3.1/32.783 > | MIME-Version: 1.0 > | Content-Type: text/plain; charset=us-ascii > | Content-Transfer-Encoding: 7bit > | Lines: 42 > | X-Trace: > sv3-2vkvCMoImkATxChi91fwCMyfSBAFekgHAyqH20qe1gaPyN5XcglRh8+nkyFdA5Mmn33cijYq > pdR2DYe!lkh4NF4DAyyAsJEa66Ev0gO/0ygDEzQxoF8qBIVTFvOLLJgBfeo5Pt7e76a09Fk46mpw > zg== > | X-Complaints-To: ab***@giganews.com > | X-DMCA-Notifications: http://www.giganews.com/info/dmca.html > | X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers > | X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your > complaint properly > | X-Postfilter: 1.3.32 > | Path: > TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onli > ne.de!border2.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.gigan > ews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail > | Xref: TK2MSFTNGXA02.phx.gbl > microsoft.public.dotnet.framework.aspnet:366737 > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet > | > | I'm starting to play around with VS2005 and ASP.NET 2 and have some > questions. > | > | The typical pattern for a data-driven aspx page in v1.1 was data > connection -> data adapter -> dataset -> bound controls. V2 (at > | least by default) doesn't include data connections, data adapters or > datasets in the toolbox when building an aspx page. Nor can I > | find where the DataView component went to. Everything now seems to rely > on the DataSource controls. > | > | Some examples (to which I would appreciate responses on "here's how it's > done in v2"): > | > | 1) If I want to present two different views of the same data -- where I > would previously declare two separate DataView components > | onto the design surface of a page and then bind controls to them -- must > I create two different data sources? This sounds like I'm > | buying into multiple requests against the database for essentially the > same data. > | > | 2) One pattern I used a lot in v1.1 was to define a current record > object > (for either the form or a row in a databound control), and > | then use it to return values to display. For example, suppose a record > in > the database had two fields, Title and DateChanged. I > | would concatenate these two fields in a protected method called from > within, say, a DataRepeater: > | > | protected string TitleAndDate( DataRowView curDRV ) > | { > | some_data_set.row_type strongly_typed_row = (some_data_set.row_type) > curDRV.Row; > | > | return strongly_typed_row.Title + " (" + > strongly_typed_row.DateChanged.ToShortDateString() + ")"; > | } > | > | And yes, I know I could do this through databinding expresssions, but > frankly they were a pain in the butt to configure; this way > | may have been less efficient, but it was clearer. At least to me :). > | > | But in v2 the Datasource control doesn't seem to return a strongly-typed > collection of objects. In fact, there doesn't seem to be > | any "knowledge" of the underlying database schema exposed in the return > value of, say, its Select() statement (clearly the schema is > | contained in the Datasource control, but it seems hidden...or at least I > haven't been able to find it). > | > | How do I get access to strongly-typed values from a Datasource control > so > I can do things like I was used to doing in v1.1? > | > | Frankly...so far I am deeply underwhelmed by the supposed productivity > improvements in v2. They may be there -- okay, they are > | almost certainly there -- but the overall approach to building websites > is so radically different in ASPNET2 that I'm going to > | suffer a major productivity hit just figuring out how to get started. > | > | It also seems like the v2 framework is more restrictive, in the sense > that it lets you do things simply -- provided you do them in a > | particular way. I understand that's the nature of a framework, but good > frameworks strike a balance between restrictions and > | flexibility. Maybe it's just the radical change from v1.1 to v2, but so > far all I see is a lot more restrictions, and a lot less > | access to the plumbing. > | > | - Mark > | > > SqlDataSource should crawl under a rock and die :) It's a fine I agree 100%. There was also interesting discussion about it (declarative > implementation if the documentation properly explains that by using it you > absolutely destroy any chance of having a properly layered system. In > some cases that's acceptable (like a prototype, or your mom's webpage), in > all others the benefits are probably far outweighed by the drawbacks. model) a while ago in case you're interested http://aspadvice.com/blogs/joteke/archive/2005/10/31/13492.aspx Steven,
Yes, it does, thanks. But I'm still confused about how I go about using strongly-typed datasets. Are you saying that to do that I should be using ObjectDataSource instead of SqlDataSource? It sounds like SqlDataSource is intended more for quick and simple applications. Is that your point? - Mark Hi Mark,
Thanks for your response. Yes, SqlDataSource is a encapsulated component for retrieving data records through DataSet or DataReader ..... And it is mainly used for simple DataBinding where we don't need additional customization on the datasource.... Also, as some other members have mentioned, it's useful when we'd like to build a rapid data access application or a prototype at designing time..... In addition, for "using strongly-typed datasets", you can use the new TableAdapter in ADO.NET 2.0 to query data and return strong-typed DataSet, (VS2005 IDE has wizard for creating TableAdapter when creating strong-typed dataset from Tables....) #TableAdapter Overview http://msdn2.microsoft.com/en-us/library/bz9tthwx.aspx And TableAdpater can be used together withe the ObjectDataSource. Of course, if you need more advanced customization, we can create our own data access component class which use TableAdapter/Typed dataset internally , and the ObjectDatasource use our own data access class.... Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.) -------------------- | NNTP-Posting-Date: Fri, 23 Dec 2005 10:27:02 -0600 <rVbr0z7BGHA.1***@TK2MSFTNGXA02.phx.gbl>| From: Mark Olbert <ChairmanMAO@newsgroups.nospam> | Newsgroups: microsoft.public.dotnet.framework.aspnet | Subject: Re: ASPNET2 Radically Changed from v1.1 | Date: Fri, 23 Dec 2005 08:27:35 -0800 | Organization: Olbert & McHugh, LLC | Reply-To: m***@arcabama.com | Message-ID: <889oq15v1cen7v3oi0f2ob645r9otoe***@4ax.com> | References: <e6anq15m1durd4pitfm9i78rm6g39nk***@4ax.com> | X-Newsreader: Forte Agent 3.1/32.783 sv3-uWLLg8KBna6ac3fBZW+4BQQGenukNm88V1SQhlOaspYf5dDxKpoFas3LJBRkheKBt6ufoSi1| MIME-Version: 1.0 | Content-Type: text/plain; charset=us-ascii | Content-Transfer-Encoding: 7bit | Lines: 9 | X-Trace: wDFJU4o!3re6g9Q2SXnpuG6UVKwOMHpSioCF6ynOkHaY5Kt8bFKTaRVz21KQ+Lu/rGy8kgH4W5w1 Sw== | X-Complaints-To: ab***@giganews.com TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fa| X-DMCA-Notifications: http://www.giganews.com/info/dmca.html | X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers | X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly | X-Postfilter: 1.3.32 | Path: stwebnet.it!tiscali!newsfeed1.ip.tiscali.net!proxad.net!64.233.160.134.MISMA TCH!postnews.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp. giganews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for- | Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.aspnet:366796| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet datasets. Are you saying that to do that I should be using| | Steven, | | Yes, it does, thanks. | | But I'm still confused about how I go about using strongly-typed | ObjectDataSource instead of SqlDataSource? It sounds like SqlDataSource is intended more for quick and simple applications. Is thatShow quoteHide quote | your point? | | - Mark |
Other interesting topics
HELP: Table height in the new XHTML???
How to Remote a custom membership or profile provider ??? ASP.NET 2.0: Global.asax Design Surface Gone Populating FormView (asp.net 2.0 using vb.net) Adding domain user to local groups Where to set timeout Casting Error AddDays exception when subtracting value Quotes, tags, and "greater than" signs GridView with dropdown: asp.net 2.0 |
|||||||||||||||||||||||