Help, how to remove elements from a datalist in c #

0

I am working on a web application in ASP.Net, and I have a datalist that contains several elements including a label.

That label has a data that I get from a database in SQL but, at the time of making the call to obtain the data of that label, its identifier does not appear, because it is inside the Datalist.

I want to know how you could look for that label or get the information you have.

 <asp:DataList ID="dtlEventos" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" CellPadding="1" CellSpacing="1">
    <ItemTemplate>
        <div class="view view-first">
            <asp:Image ID="ImgEventos" runat="server" style="width:auto;" CssClass="centered img-responsive" Height="100%" ImageUrl='<%# "/Imagenes/" + Eval("foto") %>' />
            <div class="mask">
                <h2><asp:Label ID="blbNomEvento" runat="server" Text='<%# Eval("nom_evento") %>' ></asp:Label></h2>

                <br>
                <br></br>
                <asp:Button ID="btnViewmore" runat="server" OnClick="btnViewmore_Click" Text="Ver más" />
                </br>
            </div>                            
        </div>
    </ItemTemplate>
</asp:DataList>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    
asked by NecroAny 24.07.2017 в 04:28
source

1 answer

0

It seems that I can understand your question, this is the code that you are going to add from the server side in C #:

protected void Button1_Click(object sender, EventArgs e) { ImageButton ib = (ImageButton)sender; Panel Panel = (Panel)ib.Parent; DataListItem Fila = (DataListItem)Panel.Parent; Label Id = (Label)Fila.Controls[1]; Session["idServicio"] = Id.Text; Response.Redirect("DetalleProducto.aspx"); }

In my case I use an ImageButton to send to my next page in your case I see that you use a Button to capture the data. in the line Label Id = (Label)Fila.Controls[1]; Czech because in my code I put it at the beginning of all the elements asp.net I hope to help.

    
answered by 24.07.2017 / 06:09
source