M
Mark Olbert
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
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