where to put the objectdatasource of a user control

D

djionel82

I have a user control which needs to display some data.
Where should I place the the objectdatasource that holds the data?
I have threee options:
1. I define the object data source in the page where the control is
used and in the ascx page of the user control, I refer the
objectdatasource. The drawback is that I have to define the
objectdatasource with the same ID as the user control expects.
2. I can overcome the drawback from 1. by exposing a propertz that can
set the ID of the objectdatasource. But what i still don't like about
this solution is that I have the usercontrol and the objectdatasources
defined in two separated pages.
3. I can define the object data source inside the user control and I
can expose it through a public property. this way i have access to the
objectdatasource of the user control and I don't have to clutter may
page with object datasource needed only for the user control.

which is the best practice?

Thanx,
Ionel
 
C

Cowboy \(Gregory A. Beamer\)

Feed the bits to the control from the page and you have overcome the
drawback of option #1. You can create a property on the control to feed it.
Don't set the id, but rather, feed the actual data you need to bind. Hope
this makes sense.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box! |
*************************************************
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top