How to copy a Repeater on the same page

Asked

Viewed 180 times

6

I have a Repeater control with data filled in an aspx page, the same page has the modal, the modal appears when clicking a button. How to reuse the same Reset to list in modal?

Repeater:

 <asp:Repeater ID="rptPagamentos" runat="server" OnItemDataBound="rptPagamentos_ItemDataBound">
        <ItemTemplate>
            <div class="contexto">
                <span class="font00">Tipo: </span><span class="font01">
                    <asp:Literal ID="ltTipoPagamento" runat="server"></asp:Literal>
                </span>
                <br />

                <span class="font00">Parcelas: </span><span class="font01">
                    <asp:Literal ID="ltParcelasPagamento" runat="server"></asp:Literal>
                </span>
                <br />
                <span class="font00">Valor: </span><span class="font01">
                    <asp:Literal ID="ltValorPagamento" runat="server"></asp:Literal>
                </span>
            </div>
            <br />
            <span class="linha-busca"></span>
        </ItemTemplate>
    </asp:Repeater>

Modal

  <div class="modal fade open" id="myModal" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog">

        <div class="modal-content">
            <div class="modal-header">
                <b>Pedido enviado com sucesso!</b>
                <span><strong>Pedido: </strong></span>
                <asp:Literal ID="LtSeqModal" runat="server"></asp:Literal>
                </span>
            </div>
            <div class="modal-body">
               QUERO O REPEATER AQUI
               QUERO O REPEATER AQUI
            </div>
            <div class="modal-footer">
                <div class="col-sm-12" align="center">

                    <asp:LinkButton ID="LinkButton2" CssClass="btn btn-default" runat="server" OnClick="LinkButton2_Click">Ok</asp:LinkButton>


                </div>
            </div>
        </div>
    </div>
    </div>

How to use the same Reset on the same page inside the modal?

  • You want to display the Repeat data in Modal, ie make a copy of it in Modal?

  • yes, exactly...

2 answers

1

Do so, if just to present the reapeater, without any action, you can copy the generated html at runtime and play in your div .modal-body.

You first take the generated clientId for your Peater, then make a clone and play in your div, without needing to create a controller and scaled it.

var stormTrooper = $('#myRepeaterId').clone(); //Clona o html do objeto.
$('.modal-body').append(stormTrooper); //Renderiza o clone do repeater

Less code, cleaner code.

0

Friend, Could solve your problem maybe if you put the Repeater inside a Usercontrol and used it in place of the current Repeater and inside <div class="modal-body">...</div>. This would solve the same layout problem, but not the persistence problem (after all they would still be different instances). To persist the same data, the most practical I think would be to click to display modal, copy the values of the internal fields (in this case, the Datasource) and fill in the modal. The loaded Datasource would always be the same object, passed to the two instances of Usercontrol. When returning to the screen of the first Repeater, the same process would have to be done in reverse. This supposes that the two should appear separately to the user, because otherwise, the only way to make the user type in one place and update in the other would be by placing change events in each of the fields and automatically filling in the other (by code Behind giving postback or even javascript).
I’m not sure how the solution works, I hope to help.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.