Repeater, Table, and Updatepanel - Not Working Correctly (ASP.NET)

0

I would like your help with Repeater, Table and UpdatePanel together in ASP.NET using C #.

What do I need? I have category and items (with weight) and the user needs to set a note for that item. In CodeBehinde I add weight with note and I have a result.

What is my problem? I can get a return correctly (values), but it is getting off of my Table (which work with Repeater).

I searched for a lot of solution, but nothing is working. I hope someone can help me.

Thank you.

ASPX:

 <asp:ScriptManager ID="SM1" runat="server" EnablePartialRendering="true"> </asp:ScriptManager>
            <asp:Repeater ID="RepeaterItem" runat="server" OnItemDataBound="RepeaterItem_ItemDataBound" 
                            OnItemCommand="RepeaterItem_ItemCommand" 
                            onitemcreated="RepeaterItem_ItemCreated" >
                <HeaderTemplate>
                <table class="table table-condensed" style="border-collapse:collapse; font-size:14px">
                        <thead>
                        </thead>
                </HeaderTemplate>

                <ItemTemplate>
                    <tbody class="border border-0">
                        <tr> 
                            <td class="col-1 border border-primary"> <asp:Label  ID="LabelId" runat="server" Text=""></asp:Label> </td>                                
                            <td class="col-2 border border-primary text-center"> <asp:Label  ID="LabelNome" runat="server" Text=""></asp:Label> </td>
                            <td class="col-1 border border-primary text-center"> <asp:Label  ID="LabelValor" runat="server" Text=""></asp:Label> </td>
                            <td class="col-1 border border-primary text-center"> <asp:TextBox CssClass="form-control"  AutoPostBack="true" ID="textFunc" OnTextChanged="textFunc_OnTextChanged" runat="server" type="number" Text="" value="5" min="0" max="5" maxlength="1"></asp:TextBox> </td>

                   <asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >        
                        <ContentTemplate>
                            <td > <asp:Label ID="LabelResultadoFinal" runat="server" Text="."></asp:Label></td>            
                        </ContentTemplate>
                         <Triggers>
                <asp:AsyncPostBackTrigger ControlID="textFunc" EventName="TextChanged"/>
             </Triggers>
                    </asp:UpdatePanel>     
                            <td class="col-1 border border-primary text-center"> <input  type="button" id="testButton" data-target='<%#"#accordion" + DataBinder.Eval(Container.DataItem,"ID") %>' data-toggle="collapse" value="+"></input></td>
                        </tr>
                        <tr>
                            <td colspan="5" class="hiddenRow">
                                <div class="accordian-body collapse" id="accordion<%# DataBinder.Eval(Container.DataItem, "Id")%>">   
                                    <textarea class="form-control mt-2 mb-2 col-8" id="Textarea<%# DataBinder.Eval(Container.DataItem, "Id")%>" rows="3"></textarea>
                                </div>
                            </td>
                        </tr>
                    </tbody>

                </ItemTemplate>
                <FooterTemplate>
                </table>
                </FooterTemplate>
            </asp:Repeater>

C #:

 ToolBOX.BLL.Relatorio.RelatorioLigacaoBO relatorioSelecionado;     
 protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            relatorioSelecionado = new ToolBOX.BLL.Relatorio.RelatorioLigacaoBO();
             RepeaterItem.DataSource = relatorioSelecionado.ObterItensPorCategoria(1);
            RepeaterItem.DataBind();

       }

 protected void RepeaterItem_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            ClassAuditoriaItem Item = (ClassAuditoriaItem)e.Item.DataItem;


            Label LabelId = (Label)e.Item.FindControl("LabelId");
            Label LabelNome = (Label)e.Item.FindControl("LabelNome");
            Label LabelValor = (Label)e.Item.FindControl("LabelValor");
            System.Web.UI.HtmlControls.HtmlInputText tx1 = (System.Web.UI.HtmlControls.HtmlInputText)e.Item.FindControl("text1");


            LabelId.Text = Item.Id.ToString();
            LabelNome.Text = Item.Nome;
            LabelValor.Text = Item.Valor.ToString();

        }
    }

 protected void textFunc_OnTextChanged(object sender, EventArgs e)
    {
        TextBox TextBoxNota = ((TextBox)(sender));

        RepeaterItem rp1 = ((RepeaterItem)(TextBoxNota.NamingContainer));


        Label LabelValor = (Label)rp1.FindControl("LabelValor");
        Label LabelResultadoFinal = (Label)rp1.FindControl("LabelResultadoFinal");

        LabelResultadoFinal.Text =  Convert.ToString((Convert.ToDouble(LabelValor.Text) / 5) * Convert.ToDouble(TextBoxNota.Text));



    }

In the end, the calculation works, but it is not replacing the original fields. It adds new fields to the top page.

Here what is heppening

Thank you in advance for all your help.

    
asked by anonymous 18.06.2018 / 17:14

0 answers