views:

28

answers:

1

Just ran into some interesting problem. I've separated a panel from a asp:Content block to another. In the original asp:Content block still resides a asp:FormView with childs, which references multiple ObjectDataSources. These ObjectDataSource are defined in the same asp:Content block.

The separated panel has child controls which are using the same ObjectDataSources. However, because of the separation, these ObjectDataSources aren't accessible anymore...

Simplified situation:

<asp:Content ID="ContentsContent" ContentPlaceHolderID="ContentsContainer" runat="server">
    <asp:FormView DataSourceID="FirstSource">
        <asp:DropDownList DataSourceID="SecondSource" />
    </asp:FormView>
    <asp:ObjectDataSource ID="FirstSource" />
    <asp:ObjectDataSource ID="SecondSource" />
</asp:Content>
<asp:Content ID="ModelBoxesContent" ContentPlaceHolderID="ModalBoxesContainer" runat="server">
    <asp:Panel>
        <asp:DropDownList DataSourceID="SecondSource" />
    </asp:Panel>
</asp:Content>

I understand that the scope of this Content blocks doesn't allow it... But does anyone have a nice solution to define the same datasource at one place, but still be able to reference them in multiple Content blocks?

Thanks.

A: 

set the datasource id on page load

seconddropdownlist.DataSourceID="SecondSource"  ;
Amgad Fahmi
Of course, nice solution. Hoped for something more declaratively, but this will do too.
Monty