where to put the objectdatasource of a user control

  • Thread starter Thread starter djionel82
  • Start date Start date
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
 
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! |
*************************************************
 
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! |
*************************************************
 
Back
Top