Update a Repeater after inserting a new row in the Table?

Asked

Viewed 227 times

2

Good morning, you guys!

I have a table that is populated with a Repeater. This table has a filter, which is programmed all via javascript from a ready Layout. After adding a new value to the table and using its filter, only the initial values appear when the table has been loaded.

Table structure:

<div id="divtabela" class="col-md-12 col-sm-12 col-xs-12 table-responsive table-red filter-right">
              <table id="tabelaprodutos" class="table table-striped table-hover table-dynamic">
               <thead>
                  <tr>
                     <th>Descrição</th>
                     <th>Item</th>
                   </tr>
                </thead>
                <tbody>
                    <asp:Repeater runat="server" ID="rptProdutos">
                         <ItemTemplate>
                              <tr>
                                 <td style='vertical-align: middle;'><%# rptPostNome(Container) %></td>
                                 <td style='vertical-align: middle;width:25%'><%# rptPostAtivo(Container) %></td>  
                             </tr>
                         </ItemTemplate>
                   </asp:Repeater>
                 </tbody>
              </table>
    </div>

I add a value to this table via Ajax(I add also in the database, in the same request):

$.ajax({
         type: "POST",
         url: "novoDispositivo.aspx/testeajax",
         data: '{produto: ' + JSON.stringify(produto) + '}',
         contentType: "application/json; charset=utf-8",
         dataType: "json",
         success: function (response) {

                        if (response.d != "") {

                        var quebra = response.d.split('~~');

                        $("#tabelaprodutos")
                        .prepend(
                            "<tr role='row'><td style='vertical-align: middle;'>"
                              + quebra[0] +
                            "</td><td style='vertical-align: middle;'>"
                              + quebra[1] +
                            "</td><td style='text-align:right; padding-right:50px'>"  
                              + quebra[2] +
                            "</td></tr>" 
                         );

So far everything works perfectly, adds in the bank and populates the table.

It happens that when I use the Filter, it disappears with the new values added in the table. And it only comes back when I do a postback, update the page or the like.

Is there any way I can update my Repeater data without postback? So when I use the filter it recognizes these new added values?

Thank you very much in advance!

  • Do you know or have you tried using an Updatepanel? It may serve http://www.asp.net/web-forms/overview/older-versions-getting-started/aspnet-ajax/understanding-asp-net-ajax-updatepanel-triggers

No answers

Browser other questions tagged

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