Hello .. I have the following working component:
<ig:WebDropDown ID="wddCoType" runat="server" DropDownContainerMaxHeight="500px" DropDownContainerWidth="290px" Height="20px" Width="280px" AutoPostBack="True" CssClass="wddMarginFix" DisplayMode="DropDownList" EnableClosingDropDownOnSelect="true" DropDownContainerHeight="320px"> <%--CssClass="wddSmallFnt wddMarginFix"--%> <Items> <ig:DropDownItem> </ig:DropDownItem> </Items> <ItemTemplate> <ig:WebDataTree ID="wdtCoType" runat="server" DataSourceID="whds" Height="300px" Width="250px" OnSelectionChanged="wdtCoType_SelectionChanged" SelectionType="Single"> <ClientEvents SelectionChanging="wdtCoType_SelectionChanging" SelectionChanged="wdtCoType_SelectionChanged" /> <DataBindings> <ig:DataTreeNodeBinding DataMember="SqlDSCategory_DefaultView" KeyField="CATEGORY_ID" TextField="DESC" ValueField="CATEGORY_ID" /> <ig:DataTreeNodeBinding DataMember="SqlDSBizCat_DefaultView" KeyField="CATEGORY_ID" TextField="TYPE_DESC" ValueField="TYPE_ID" /> <ig:DataTreeNodeBinding DataMember="SqlDSBizCodes_DefaultView" KeyField="TYPE_ID" TextField="descr" ValueField="CODE" /> </DataBindings> </ig:WebDataTree> </ItemTemplate> </ig:WebDropDown> <ig:WebHierarchicalDataSource ID="whds" runat="server"> <DataViews> <ig:DataView ID="SqlDSCategory_DefaultView" DataMember="DefaultView" DataSourceID="SqlDSCategory" /> <ig:DataView ID="SqlDSBizCat_DefaultView" DataMember="DefaultView" DataSourceID="SqlDSBizCat" /> <ig:DataView ID="SqlDSBizCodes_DefaultView" DataMember="DefaultView" DataSourceID="SqlDSBizCodes" /> </DataViews> <DataRelations> <ig:DataRelation ChildColumns="CATEGORY_ID" ChildDataViewID="SqlDSBizCat_DefaultView" ParentColumns="CATEGORY_ID" ParentDataViewID="SqlDSCategory_DefaultView" /> <ig:DataRelation ChildColumns="TYPE_ID" ChildDataViewID="SqlDSBizCodes_DefaultView" ParentColumns="TYPE_ID" ParentDataViewID="SqlDSBizCat_DefaultView" /> </DataRelations> </ig:WebHierarchicalDataSource> <asp:SqlDataSource ID="SqlDSBizCodes" runat="server" ConnectionString="<%$ ConnectionStrings:JNJ GTW %>" SelectCommand="select bc.TYPE_ID, bc.CODE + space(3) + bc.[DESC] as descr , bc.CODE from dbo.bizcodes bc order by BC.[ORDER]"></asp:SqlDataSource> <asp:SqlDataSource ID="SqlDSBizCat" runat="server" ConnectionString="<%$ ConnectionStrings:JNJ GTW %>" SelectCommand="select ct.CATEGORY_ID , ct.TYPE_DESC, ct.TYPE_ID from dbo.BIZ_CATEGORY_TYPE ct"></asp:SqlDataSource> <asp:SqlDataSource ID="SqlDSCategory" runat="server" ConnectionString="<%$ ConnectionStrings:JNJ GTW %>" SelectCommand="SELECT [DESC], CATEGORY_ID FROM CATEGORY AS ca WHERE (CODE = 1)"></asp:SqlDataSource>
I need to accomplish the following : dynamically assign connection strings instead of the one macro substituted in templates.
In regular drop downs I just remove ConnectionString rom the component mark up and put into the Page_Init the following expression:
SqlDSBizCodes.ConnectionString = ConfigurationManager.ConnectionStrings[_sessionTDUToken.dbConnectionName].ConnectionString;
It works everywhere except this particular component.. If I remove all three ConnectionString="<%$ ConnectionStrings:JNJ GTW %>" and put three ConfigurationManager expression into Page_Init it blows up with : "The ConnectionString property has not been initialized."
Would you advise how to dynamically change reference to the connection string in this particular scenario.. again the method works for all other WebDropDown(s)
Thanks.
Hi Michael,
I have been looking into your question and after an investigation I could say that the Page_Init event is emitted too early and there is no guarantee that the controls have been created yet. Having this in mind, my assumption is that this could cause the described error.
An approach I could suggest is to set the ConnectionString later - for example in the OnInit event on WebDropDown.
Attached could be found my sample for your reference. Please test it on your side and let me know how it behaves. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me along with steps to reproduce.
Please let me know if you need any further assistance regarding this matter.
Regards,
Aleksandar Atanasov,
Infragistics.
SQLConnectionString.zip
Thanks, it solved the issue.