为什么更改datapager索引后我丢失了过滤结果

问题描述

enter image description here

查看Gif并查看问题,当我在其他页面上单击搜索条件后,在文本框中键入并搜索结果就很好

解决方法

<head runat="server">
<title></title>
<link href="App_Themes/Theme1/CSS/Usual.css" rel="stylesheet" />
<link href="Table.css" rel="stylesheet" />
<style>
    body
    {
        font-family: Poppins !important
    }

    input
    {
        font: unset !important
    }
</style>
<script>
    function UpdatePanel() {
        __doPostBack("<%=TextBox1.ClientID%>",'')
    }
</script>
<link href="App_Themes/Theme1/CSS/Bootstrap.css" rel="stylesheet" />
与身体
<body>
<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div class="table-b">
        <div class="row d-flex justify-content-center">
            <div class="col-md-6">
                <div class="tables">
                    <div class="table-search">
                        <asp:TextBox AutoCompleteType="None" ID="TextBox1" onkeyup="UpdatePanel()" AutoPostBack="false" OnTextChanged="TextBox1_TextChanged" CssClass="key" runat="server" placeholder="Search"></asp:TextBox>
                        <div class="line-1"></div>
                        <div class="line-0"></div>
                    </div>
                    <asp:UpdatePanel ID="UpdatePanel1" RenderMode="Block" UpdateMode="Conditional" runat="server">
                        <ContentTemplate>
                            <asp:ListView  ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="product_id">
                                <ItemTemplate>
                                    <tr style="">
                                        <td>
                                            <asp:Label Text='<%# Eval("product_id") %>' runat="server" ID="product_idLabel" />
                                        </td>
                                        <td>
                                            <asp:Label Text='<%# Eval("product_name") %>' runat="server" ID="product_nameLabel" />
                                        </td>

                                        <td>
                                            <asp:Label Text='<%# Convert.ToInt32(Eval("list_price")).ToString("N0") %>' runat="server" ID="list_priceLabel" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                                <LayoutTemplate>
                                    <table runat="server" style="width: 100%; text-align: right">
                                        <tr runat="server" class="thead">
                                            <th runat="server">id</th>
                                            <th runat="server">name</th>
                                            <th runat="server">price</th>
                                        </tr>
                                        <tr runat="server" id="itemPlaceholder"></tr>
                                        <tr runat="server">
                                            <td runat="server" style="">
                                                <asp:DataPager runat="server" ID="DataPager1">
                                                    <Fields>
                                                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False"></asp:NextPreviousPagerField>
                                                        <asp:NumericPagerField></asp:NumericPagerField>
                                                        <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False"></asp:NextPreviousPagerField>
                                                    </Fields>
                                                </asp:DataPager>
                                            </td>
                                        </tr>
                                    </table>
                                </LayoutTemplate>
                            </asp:ListView>
                            <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:ProductConnectionString %>' SelectCommand="SELECT product_name,product_id,list_price FROM production.products"></asp:SqlDataSource>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="TextBox1" EventName="TextChanged" />
                        </Triggers>
                    </asp:UpdatePanel>
                </div>
            </div>
        </div>
    </div>

</form>

这是背后的代码

 protected void TextBox1_TextChanged(object sender,EventArgs e)
{
    SqlDataSource1.SelectCommand = "SELECT product_name,list_price FROM production.products where product_name like '%" + TextBox1.Text + "%'";
    SqlDataSource1.DataBind();
    ListView1.DataBind();
}

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...