Problem with a Gridview filter

0

I have a Gridview that loads the data using a method from a TableAdapter. I need to filter by typing in a TextBox.

I have this but it does not work:

<asp:TextBox  class="form-control" id="filtroAcompanantes" runat="server" />
<asp:GridView ID="grdAcompanantes" class="filtrar" runat="server" Style="margin-top: -1px; line-height: 30px; font-size: 14px;" AllowPaging="false"
    AllowSorting="True" Width="100%" AutoGenerateColumns="false" onrowcommand="grdAcompanantes_RowCommand" Visible="true" EmptyDataText="No se han encontrado resultados."
    meta:resourcekey="grdAcompanantesResource">
    <Columns>
        <%--CHECKBOX--%>
        <asp:TemplateField HeaderText="">
            <ItemTemplate>
                <asp:CheckBox ID="chkAcompanantes" runat="server" CausesValidation="false"
                    CommandArgument='<%# DataBinder.Eval(Container.DataItem, "AGT_ID")%>' />
            </ItemTemplate>
            <ItemStyle Width="10px" HorizontalAlign="Center" />
        </asp:TemplateField>
        <%--ACOMPAÑANTE--%>
        <asp:TemplateField HeaderText="Acompañantes">
            <ItemTemplate>
                <asp:Label ID="LblNombreAcompanantes" runat="server" Style="margin-left: 5px;"
                    Text='<%# DataBinder.Eval(Container.DataItem, "AGT_Nombre")%>' />
            </ItemTemplate>
            <ItemStyle Width="200px" />
        </asp:TemplateField>
    </Columns>
    <RowStyle CssClass="RowStyle" BorderColor="#F6F7F9" />
    <SelectedRowStyle CssClass="SelectedRowStyle" />
    <HeaderStyle BackColor="#D6D7DB" Font-Bold="True" HorizontalAlign="Center" Height="10px" />
    <AlternatingRowStyle CssClass="AlternatingRowStyle" />
</asp:GridView>

This TextBox event:

Protected Sub filtroacompanante(ByVal sender As Object, ByVal e As EventArgs)
    grdAcompanantes.DataSource = dat.obtener("select * from view_gc_ext_Agentes where AGT_Nombre like '%" & filtroAcompanantes.Text & "%'")
    grdAcompanantes.DataBind()
    Lbl.Text = filtroAcompanantes.Text
End Sub  
    
asked by Jeison Torres 23.01.2018 в 02:42
source

0 answers