Click here to Skip to main content
15,918,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!! I was wondering if it is possible to repeat the data in the button AND the modal that matches the data together. At the moment, I have a list of buttons with the right data, but when clicking on any of them it always appears to have the first data in the modal.

Sorry for such a long piece of code :P


<asp:Repeater ID="rptMain" runat="server">
                                        <ItemTemplate>
                                        <div>
                                        <div class="list-group">
    <a href="#" class="list-group-item" data-toggle="modal" data-target="#editmember">
      <p class="list-group-item-text"><%#Eval("name")%> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></p>
</a>
</div>

                                        <div class="modal fade" id="editmember" role="dialog">
    <div class="modal-dialog">
    
      
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"</button>
          <h4 class="modal-title"><%#Eval("name")%> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></h4>
        </div>
        <div class="modal-body">
          <p><div style="float: left; width: 100%;">
                                                    <div style="float: left; width: 13%;">
                                                        <asp:Image ID="imgPhoto" runat="server" Style="width: 90px; -moz-border-radius: 4px;border-radius: 4px;"
                                                             Visible='<%#Eval("photo").ToString()==""?false:true %>'
                                                            ImageUrl='<%#Eval("photo").ToString()==""?"photo\\no_noimage.png" : "photo\\" + Eval("photo").ToString()%>' />
                                                    </div>
                                                    <div style="float: left; width: 87%;">
                                                        <p>
                                                            <%#Eval("ContactBio")%>
                                                        </p>
                                                    </div>
                                                </div>
                                                <p>
                                                     
                                                </p>
                                                <div style="float: left; width: 100%;">
                                                    <div style="float: left; width: 13%;">
                                                        <asp:Image ID="imgLogo" runat="server" Style="width: 90px; -moz-border-radius: 4px;border-radius: 4px;"
                                                             Visible='<%#Eval("logo").ToString()==""?false:true %>'
                                                            ImageUrl='<%#Eval("logo").ToString()==""?"logo\\no_noimage.png" : "logo\\" + Eval("logo").ToString()%>'/>
                                                    </div>
                                                    <div style="float: left; width: 87%;">
                                                        <p style="font-weight: bold;">
                                                            <%#Eval("subcompany")%>
                                                        </p>
                                                        <p>
                                                            <%#Eval("CompanyDescription")%>
                                                        </p>
                                                    </div>
                                                    </div>
                                                    
                                                
                                                <p>
                                                     </p></p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
        </div>
        </div>
        </div>
        </div>
                                        
  
                                        </ItemTemplate>
                                    </asp:Repeater>


I would really appreciate some help with this :)
Posted

see the problem is all your buttons data-target attribute targets to first modal of the page with id of target, so better give target by using class names as data-target, and generate unique class names for each model, and give those in corresponding button target.

You can also handle these with jquery , like generate click event for buttons with particular class name, in that click event get the current target model class name using some data-classname="targetmodelclassname" and then open that modal calling open.

better to follow first one, just generate unique names for models, and target them in buttons.

Hope it will help you.
 
Share this answer
 
Comments
Member 11909898 14-Aug-15 16:28pm    
thank you for your response.

could you give me an example on how to link to the data target?
aspdotnet sekhar 14-Aug-15 23:45pm    
You probably have the unique id associated with that row, and use that for generating class name see below code, replace your uniqueid
 <itemtemplate>
                                        <div>
                                        <div class="list-group">
    <a href="#" class="list-group-item" data-toggle="modal" data-target=".<%#Eval(" youruniqueid=")%>">
      <p class="list-group-item-text"><![CDATA[<%#Eval("name")%>]]> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></p>
</a>
</div>
 
                                        <div class="modal fade <%#Eval(" youruniqueid=")%>" id="editmember" role="dialog">
    <div class="modal-dialog">
    
      
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal"</button>
          <h4 class="modal-title"><![CDATA[<%#Eval("name")%>]]> <%#Eval("lastname")%>, <%#Eval("jobtitle")%>, <%#Eval("subcompany")%>, <%#Eval("country")%></h4>
        </div>


</div></div></div></div></itemtemplate>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900