Data layer experts - Please Help!

W

William Buchanan

Hi folks

Can anyone point me in the direction of any information on how to make a
data layer which will work with the new ASP.NET 2.0 data components
(GridView, etc)?

The reason I ask is because I want to have my data layer in a totally
separate assembly. However, this doesn't seem possible. Let me explain....

Every site which describes how to do this seems to follow the same pattern -
half the site talks about how data layers are great, etc. Then, when it
comes to an example, they drop an SQLDataSource or an ObjectDataSource
directly on the page. Am I missing something here - to me this isn't a data
layer.

Also, when you create a DataSet in an ASP.NET application, you get different
methods to that of a DataSet in a normal assembly. In fact, in an ASP.NET
DataSet you don't even get any C# code which means that you can't use it in
normal code (so you can't create a wrapper around it). It also means that
ASP.NET components won't work with an assembly DataSet (since it doesn't
generate Insert and Delete methods) - it only generates "GetData" and
"Update".

I think I am missing some chunk of information so would be great if you
could help!

Thanks

Will
 
M

Marina Levit [MVP]

Yes, all the drag and drop designer stuff is not practical or usable when
you are designing a flexible architecture that you want to abstract.

If you want it done right, you need to do it all yourself without having the
designer do it all for you. Write your insert/update/delete/select
statements yourself, etc.
 
B

Bruce Barker

read about how to interface your data layer with ObjectDataSource. The
design of the ObjectDataSource was to be used with custom data layers.

-- bruce (sqlwork.com)
 
S

sloan

Those new things are developed for "Rapid Development"...not necessarily
"well designed tiered development".

You want to the use the alternate ObjectDataSource instead.

The way I've been doing it, (but I'm not expert, and still learning 2.0) is
that I
call the business object which returns a Collection usually (my own
implemented CollectionBase)
and then I bind the ObjectDataSource1 (because its dragged on the page) to
the MyCollection.
Then the Grid is bound to the ObjectDataSource1.

I consider MyCollection as the model, and the ObjectDataSource1 is just a
helper to get it wired up to the GridView nicely.

...
 
W

William Buchanan

Thanks for the reply. I'm not going mad then!

How would you recommend I read/write to the database? In the past i've used
DataAdapter, SQLCommand, etc, but they have been hidden to persuade us to
use the new components - this has led me to believe that there is an
alternative way of doing this kind of work, although I haven't found it yet.

Thanks for your time.

Will
 
W

William Buchanan

Thanks for the info.

I have been using ObjectDataSource successfully with the GridView,
DetailsView, etc kind of thing. However, it is when I need to do some adhoc
database work that I get lost. E.g. I have a page which has a detail view
for adding a new Company record. When the page is posted back, I need to do
some updates once I have the new CompanyID. I can't see how ObjectDataSource
can let me do this - this is where I get stuck.

Would be greatful if you could help out.

Will
 
W

William Buchanan

Hi Sloan
Thanks for taking the time to reply.

How do you populate and persist your Collection object? Any chance of seeing
some example code :)

Regards
Will
 
M

Mark Rae

Yes, all the drag and drop designer stuff is not practical or usable when
you are designing a flexible architecture that you want to abstract.

If you want it done right, you need to do it all yourself without having
the designer do it all for you. Write your insert/update/delete/select
statements yourself, etc.

I couldn't agree more!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top