How to access page property (or just controls in it) from a custom DataSource control

Hi, I am currently working on a number of various custom datasource controls. I've found the solution for most problems on the way so far, but now I really got stuck. One of my controls will take a set of various input parameters, similar to the good old SQLDataSource control. One of my parameter classes is supposed to take a value from an arbitrary control on the page. Howevere, it does not seem to be an easy way to access the Page property (from inside this control) on my DataSource control. I need this to use FindControl. When I do so, from inside my "ExternalDataSource" control, the Mybase.Page property is null. BUT, if I access the Control's page property, which is indeed the very same propery, from the aspx page, it all works. To cxlearify this, look at the bold/underlined section in the code behind. If i remove this part it all works from outside the class. Otherwise it fails.

What Ive come up with so far is this:

My custom control have a collection of parameters,  the ParamCollection which holds a set of objects that inherits from my custom parameter base class "ExternalParameterBase".
Now, one of these objects is the ExternalControlParameter declared as follows on the aspx page.
 <asp:ExternalControlParameter Name="paramname1" ControlID="Textbox1" /> 

<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public Class ExternalDataSource
   Inherits DataSourceControl

Public Property InputParams As ParamCollection......
Protected Overrides Function GetView(viewName As String) As DataSourceView.......
Protected Overrides Function GetViewNames() As ICollection.........

Public Overrides Property Page() as System.Web.UI.Page
      If not is nothing then

End Class
Im not sure if I explained good enough. Anyway, Im greatful for all help on this!


3/27/2007 10:14:57 PM 3498 articles. 0 followers. Follow

0 Replies

Similar Articles

[PageSpeed] 13