Multiple ObjectDataSources?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi - I have a wizard which has about 4 RadioList controls on it, all of which
are populated from a data object. As far as best practices go, would it be
better to configure a seperate ObjectDataSource for each control, or is there
a more efficient method? If so, can you explain the implementation? Thanks!~
 
Hello Morgan,

Welcome to the MSDN newsgroup.

From your description, you're developing an ASP.NET 2.0 page which contains
several radiobutton lists, and these list will be bound to some datas
retrieved from database(through some data access classes configured in
objectdatasource). currently, you're wondering what's the recommend way to
configure the objectdatasource for those databound radiolists(one
objectdatasource per radiolist or share a single objectdatasource)
,correct? If anything I didn't quite get, please feel free to let me know.

As for this question, I think it mostly depend how your data access helper
class is designed. For example, whether the data access methods(query,
update, delete....) are class's instance methods or static methods, or is
the class has expensive construction or initializating code for creating
each instance?

1. If the class define those data access functions as instance methods,
then each objectdatasouce use this class will construct a new instance of
this class. In such scenario, it is recommended to share one
objectDataSource if possible(especially when each class instance's
constructing and initializing is expensive).

2. If you do not quite concern about the things in #1, then, either single
objectdatasource or mutiple ones is possible. For example, when the data
accessing methods are static methods of the helper class, objectdatasource
won't create any instance at runtime, so multiple datasources won't add
much overhead(from the data access class).

Just some of my understanding. If you have any other concerns or ideas,
please feel free to post here.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Thanks Steven for your quick response!

First, your explanation of the situation is right on. This is an ASP 2.0
website, with about 4 radiobuttonlists dispersed throughout a single wizard
control on a page.

However, I'm still unsure about which method would be better based on your
explanation, so let me elaborate some:

The data object class that I'm using currently has a method to pull data for
each control. So, I have radiolist1, radiolist2, radiolist3 and radiolist4
on the web page, and GetData1, GetData2, GetData3 and GetData4 method in the
data object, each of which just does a simple select statement to pull all
records from a single table (4 different tables) and return a DataTable
object. These are just lookup tables, so the number of records and columns
are pretty small (5-25 max records, 2-3 max columns). Right now it would
probably work fine with four objectdatasources, one for each method. So my
questions are:

1. Would a single objectdatasource be more appropriate in this scenario?
2. If so (and even if not, just because I'm curious) How would I modify the
my data class to support it?

I'm guessing that I would need to create a new method that would return a
single dataset with four datatables in it, but I'm not sure.

By the way, I'm using the Enterprise Library 2.0 version Data Access Blocks.

--
Morgan
Web Developer
Portland, Oregon
 
Thanks for your reply Morgan,

Based on your further description,all the data access methods have been put
in a single data access class and those methods will supply different data
to different controls. I think it's better to use multiple ObjectDataSource
controls, each of them (configuerd to use that data access class) will
supply the certain data (through certain methods) to the corresponding
radiolist control. This is more reasonable, and I don't think it is
necessary to make all the radioList controls share single objectdatasource
control.

BTW, are those methods on the class static methods? If not, I suggest you
define them as static methods so as to avoid the instance constructing
overhead.

Hope this helps.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Hi Morgan,

How are you doing on this issue? Have you got any further ideas or does my
last reply helps a little? If you have any further questions or there is
still anything we can help, please feel free to let me know.

Regards,

Steven Cheng
Microsoft MSDN Online Support Lead


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Back
Top