Ticket Q586607
Visible to All Users

ASPxDataView - Change Theme at runtime of Template Control

created 11 years ago

Hello,
I have this scenario:

ASPx
<dx:aspxdataview ID="ASPxDataViewHeadline" runat="server" RowPerPage="1" Layout="Flow" OnLoad="ASPxDataViewHeadline_Load" Width="100%"> <SettingsFlowLayout ItemsPerPage="3"></SettingsFlowLayout> <settingstablelayout rowsperpage="1" /> <PagerSettings Position="Bottom" /> <ItemTemplate> <dx:ASPxHeadline ID="ASPxHeadline" runat="server" ContentText='<%# GetContentText(Eval("FullText")) %>' Date='<%# Eval("StartDateUtc") %>' HeaderText='<%# Eval("Title") %>' TailText="<%# GetTailText() %>" EnableViewState="False" EncodeHtml="False" NavigateUrl='<%# GetNavigateUrl(Eval("Alias")) %>' Image-Url='<%# GetContentImage(Eval("ImageGallery")) %>' Image-Height="100px" Image-Width="100px"> </dx:ASPxHeadline> </ItemTemplate> </dx:aspxdataview>

I usually change them property at runtime. I need to change the same theme to both ASPxDataView and ASPxHeadline, but the latter is inside the former Template.
How can I change the templated control theme at runtime?
Thank you
Gerardo

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

Hello,

According to the ASP.NET life cycle, a theme should be changed during the Page_PreInit event.
So, I suggest that you change the page or global ASPxWebControl theme in order to apply its appearance for all nested controls using the standard practices. Please take a look at the E1342 - How to change themes on-the-fly (ASP.NET theming approach) and E5016 - How to switch themes on a Master page at runtime (DevExpress theming approach) examples to see this approach in action.

    Comments (2)

      Hello, Mike,
      yes, it's exactly what I do: I change the theme in the Pre_Init event. But I cannot find the Templated control at that stage, I mean the function "this.ASPxDataViewHeadline.FindItemControl" return null.
      Thank you

      Alessandro (DevExpress Support) 11 years ago

        This behavior is expected. At the Pre_Init stage, templates are not yet created. Nevertheless, by using the suggested approach you do not need to obtain a reference to the templated control. The theme you specified will be applied automatically.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.