Could not find control 'ControlName' in ControlParameter

Kacey Ezerioha

Kacey Ezerioha

Jun 17 2015 4:53 AM

I know that by the aforementioned topic, you might probably think it is a simple problem. But apparently, it isn't. Allow me to explain my requirement here.

I have a webforms ASP.NET application I am building with bootstrap. And there is this repeater control I built to display some data in which I attached a button in the item template for comments. And I want the button to launch a modal displaying a list of comments on that particular data item on the repeater and also have a provision for users to drop comments (something like facebook comments). Below is the markup for the bootstrap modal.

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
           <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                  <h4 class="modal-title" id="myModalLabel">Modal title</h4>
           <div class="modal-body">
                  <asp:Repeater ID="rptComments" runat="server">
                                 <div style="float: left; width: 100%;" class="bg-info">
                                       <b>'<%#GetUserInfo(Eval("UserId")) %>': </b>'<%# Eval("Comment") %>'
                                       <br />
                                       <div class="pull-right text-muted small">
                                             <em>'<%#GetTimeOfComment(Eval("DateCommented")) %>'</em>
                                 <div style="clear: both; line-height: 0px">
               <cc1:PollCommentsDataSource ID="PollCommentsDataSource1" runat="server" SelectMethod="GetByPollQuestionId"                      EnableTransaction="false">
                     <DeepLoadProperties Method="IncludeChildren" Recursive="false">
                           <asp:ControlParameter ControlID="btnModal" Name="ModalPollQuestionId" />
         <div class="modal-footer">
               <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
               <button type="button" class="btn btn-primary">Save changes</button>

I placed the above modal markup outside the repeater in which I have the button to trigger it. The reason is so the modal doesn't get hidden behind the modal background. But the problem is the datasource PollCommentsDataSource that is supposed to populate the repeater within the modal isn't finding the button because it is within the main repeater. My question is how can I get it to see the button? Doing anything in code-behind isn't an option because I don't want the button click to take a trip to the server (it will be awkward for a modal launch)

P.S The button to launch the modal is a html button (<button></button>)