views:

97

answers:

1

I have an ASCX that inherits from a WebControl that has a 'CustomConfiguration' property of type CollectionConfigurationItem. This configuration gets set elsewhere in the code, so by the time it gets to the ASCX it is set up to how I wish to use the data. At this point I'd like to render out another control using this configuration, like so:

<modules:DataModule runat="server" CustomConfiguration="<%# Model.CategoryListConfiguration %>" />

However, breaking into DataModule always results in 'CustomConfiguration' being null, which is the default value for the property. I've tried adding a Bindable attribute to the property but to no avail, and when I set an EventHandler for the DataBinding event on the DataModule it doesn't even get called.

How can I set this custom-class-typed property from the markup or, failing that what's the second-best method of getting this to work? Thanks for any light you can shed!

+2  A: 

When you use the <%# %> syntax, it doesn't get executed until you databind the control. Try calling:

yourDataModuleID.DataBind();

e.g. from your Page_Init method.

David Ebbo
I can't believe it was that simple! Thanks - I'll accept your answer when the system will let me :)
tags2k