title: How to change ConnectionString property of SqlDataSource by Code Behind which is in Child ReorderList?
body: <p>I have two <code>ReorderList</code> One is a parent and other is its child. I want to change dynamically the <code>ConnectionString</code> property of <code>SqlDataSource</code> through code behind but I am unable to change <code>ConnectionString</code> property of Child <code>ReorderList</code> even I tried <code>OnItemDataBound</code> and tried to find the control and change its property but could not. Here is a sample of code which I am using:</p>
  
  <pre><code>     &lt;div class="reorderListDemo" style="width: 100%"&gt;
      &lt;cc1:ReorderList ID="ReorderList1" runat="server" DataSourceID="SqlDataSource1" DataKeyField="RecordingFilterId" AllowReorder="true"
          SortOrderField="Priority" PostBackOnReorder="False"&gt;
          &lt;ItemTemplate&gt;
              &lt;table style="width: 100%" cellpadding="0" cellspacing="0" border="0"&gt;
                  &lt;tr&gt;
                      &lt;td width="6%" style="padding-left:5px;padding-top:3px;"&gt;
                          &lt;a href="javascript:switchViews('divRF&lt;%# Eval("RecordingFilterId") %&gt;', 'dragHandle&lt;%# Eval("RecordingFilterId") %&gt;');"&gt;
                              &lt;img id="imgdivRF&lt;%# Eval("RecordingFilterId") %&gt;" border="0" src="Images/expand.png" /&gt;
                          &lt;/a&gt;
                      &lt;/td&gt;
                      &lt;td width="34%"&gt;
                          &lt;asp:Label ID="Label7" runat="server" Text='&lt;%# Eval("Name") %&gt;' meta:resourcekey="Label7Resource1" /&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td colspan="6" width="100%" style="padding-right:10px;" &gt;
                              &lt;div id="divRF&lt;%# Eval("RecordingFilterId") %&gt;" style="display: none; width: 99%;"&gt;
                                  &lt;table style="width: 100%;" cellspacing="0" cellpadding="0" border="0" &gt;
                                          &lt;tbody&gt;
                                              &lt;tr&gt;
                                                  &lt;td style="color: white; width: 15%; padding-left: 30px;" class="topleft" align="left"&gt;
                                                      &lt;div&gt;
                                                          &lt;b&gt;
                                                              &lt;asp:Label ID="Label3" runat="server" Text="Rule" meta:resourcekey="Label3Resource2"&gt;&lt;/asp:Label&gt;&lt;/b&gt;
                                                      &lt;/div&gt;
                                                  &lt;/td&gt;
                                              &lt;/tr&gt;
                                          &lt;/tbody&gt;
                                      &lt;/table&gt;
                                  &lt;div class="reorderListDemo" style="margin-left: 0px;width: 97%;"&gt;
                                      &lt;cc1:ReorderList ID="ReorderList2" runat="server" PostBackOnReorder="False" CallbackCssStyle="callbackStyle"
                                          AllowReorder="True" DataKeyField="RuleId" SortOrderField="Priority"
                                          &gt;
                                          &lt;ItemTemplate&gt;                                                                
                                                  &lt;table style="width: 100%" cellpadding="0" cellspacing="0" border="0"&gt;
                                                      &lt;tr&gt;
                                                          &lt;td align="left" style="padding-left: 10px; width: 15%;"&gt;
                                                              &lt;asp:Label ID="Label6" runat="server" ToolTip='&lt;%# Eval("RuleName") %&gt;' Text='&lt;%# Eval("RuleName").ToString().Length &gt; 14 ? Eval("RuleName").ToString().Substring(0,12) + ".." : Eval("RuleName").ToString() %&gt;' /&gt;
                                                          &lt;/td&gt;
                                                      &lt;/tr&gt;
                                                  &lt;/table&gt;                                                              
                                          &lt;/ItemTemplate&gt;
                                          &lt;ReorderTemplate&gt;
                                              &lt;asp:Panel ID="Panel2" runat="server" CssClass="reorderCue" meta:resourcekey="Panel2Resource1"&gt;
                                              &lt;/asp:Panel&gt;
                                          &lt;/ReorderTemplate&gt;
                                          &lt;DragHandleTemplate&gt;
                                              &lt;div class="dragHandleChild" id="dragHandle&lt;%# Eval("RecordingFilterId") %&gt;"&gt;
                                              &lt;/div&gt;
                                          &lt;/DragHandleTemplate&gt;
  
                                      &lt;/cc1:ReorderList&gt;
                                      &lt;asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="&lt;%$ ConnectionStrings:MyConnectionString %&gt;"
                                          ProviderName="&lt;%$ ConnectionStrings:MyConnectionString.ProviderName %&gt;"
                                          OnDeleted="OnRuleDeleted" SelectCommand="SELECT RuleId,RecordingFilterId,RuleName,RecordingAction,RecordingCondition,ExtensionValue,Priority,CallType FROM rules  WHERE ([RecordingFilterId] =@RecordingFilterId)  and RuleName &amp;lt;&amp;gt; '' ORDER BY [Priority] asc"
                                          UpdateCommand="UPDATE [Rules] SET [Priority] = @Priority WHERE RuleId = @original_RuleID"
                                          DeleteCommand="exec DeleteRule @original_RuleID" OldValuesParameterFormatString="original_{0}"&gt;
                                          &lt;DeleteParameters&gt;
                                              &lt;asp:Parameter Name="original_RuleID" /&gt;
                                          &lt;/DeleteParameters&gt;
                                          &lt;SelectParameters&gt;
                                              &lt;asp:ControlParameter ControlID="lblCategoryName" Name="RecordingFilterId" PropertyName="Text"
                                                  Type="String" /&gt;
                                          &lt;/SelectParameters&gt;
                                          &lt;UpdateParameters&gt;
                                              &lt;asp:Parameter Name="Priority" Type="Int32" /&gt;
                                              &lt;asp:Parameter Name="original_RuleID" Type="String" /&gt;
                                          &lt;/UpdateParameters&gt;
                                      &lt;/asp:SqlDataSource&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
  
          &lt;/ItemTemplate&gt;
  
          &lt;ReorderTemplate&gt;
              &lt;asp:Panel ID="Panel2" runat="server" CssClass="reorderCue" &gt;
              &lt;/asp:Panel&gt;
          &lt;/ReorderTemplate&gt;
          &lt;DragHandleTemplate&gt;
  
              &lt;div class="dragHandle" id="dragHandle&lt;%# Eval("RecordingFilterId") %&gt;"&gt;
              &lt;/div&gt;
          &lt;/DragHandleTemplate&gt;
      &lt;/cc1:ReorderList&gt;
  
  &lt;/div&gt;
  &lt;asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="&lt;%$ ConnectionStrings:MyConnectionString %&gt;"
      ProviderName="&lt;%$ ConnectionStrings:MyConnectionString.ProviderName %&gt;"
      SelectCommand="SELECT RecordingFilterId,Name,Description,SystemFilter,Priority FROM recordingfilters WHERE SystemFilter='1' AND STATUS =1  order BY Priority"
      UpdateCommand="UPDATE [recordingfilters] SET [Priority] = @Priority WHERE RecordingFilterId = @original_RecordingFilterId"
      OnDeleted="OnFilterDeleted" DeleteCommand="exec DeleteRecordingFilter @original_RecordingFilterId"
      OldValuesParameterFormatString="original_{0}"&gt;
      &lt;DeleteParameters&gt;
          &lt;asp:Parameter Name="original_RecordingFilterId" /&gt;
      &lt;/DeleteParameters&gt;
      &lt;UpdateParameters&gt;
          &lt;asp:Parameter Name="Priority" Type="Int32" /&gt;
          &lt;asp:Parameter Name="original_RecordingFilterId" Type="String" /&gt;
      &lt;/UpdateParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>I can change the <code>ConnectionString</code> of <code>SqlDataSource1</code> through code behind and its accessible but <code>SqlDataSource2</code> is not accessible. Anyone kindly give me a clue how to achieve this as I want to assign Connection String from code behind.</p>