0

我正在开发应用程序,其中我有一个用于编写供应商的文本框,并通过调用文本更改方法显示供应商列表与输入文本匹配,并在网格视图中显示结果,但问题是,当我单击时调用该方法在文本框之外,但我想要它,只要用户在文本框中输入就触发

ASP 代码

 <table style="width: 100%;">
                <tr>
                    <td style="font-weight: bold; font-size: medium; text-align: right;">
                        &nbsp;
                        Supplier Name
                    </td>
                    <td style="text-align: left">
                        &nbsp;<asp:TextBox ID="txtSuppName" runat="server" Width="357px"></asp:TextBox>
                    </td>
                </tr>
                </table>
            <asp:Panel ID="Panel1" runat="server" Height="616px" ScrollBars="Auto">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                    <ContentTemplate>
                        <asp:GridView ID="gvSuppPayment" runat="server" AutoGenerateColumns="False" 
                            CellPadding="4" ForeColor="" GridLines="None" Width="100%"  
                            OnRowCommand="GetSuppOrderDetails" BorderStyle="Solid" CssClass="shadow">



                            <Columns>
                                <asp:TemplateField HeaderText="Emaiil ID">
                                <ItemTemplate>     
                                            <asp:LinkButton ID="restorantName" runat="server"  CommandName="Email"  CommandArgument='<%#Eval("Supp_Email_ID")+ ";" +Eval("Supp_Name")+ ";" +Eval("Area") %>'  Text='<%# Bind("Supp_Email_ID") %> '>LinkButton</asp:LinkButton>
                                   </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="Supp_Name" HeaderText="Supp Name" />
                                <asp:BoundField DataField="Area" HeaderText="Area" />
                                <asp:BoundField DataField="Total_Orders" HeaderText="Total Orders" />
                                <asp:BoundField DataField="Total_Amount" HeaderText="Total Amount" />
                                <asp:BoundField DataField="Total_Ammount_Recievable" 
                                    HeaderText="Total Ammount Recievable" />
                                <asp:BoundField DataField="Total_Ammount_Payable" 
                                    HeaderText="Total Ammount Payable" />
                                <asp:BoundField DataField="Is_Deleted" HeaderText="Is Deleted" />
                            </Columns>

                            <HeaderStyle BackColor="#454545" Font-Bold="True" ForeColor="#35a7c1" />

                            <RowStyle CssClass="cartBackground" />

                        </asp:GridView>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </asp:Panel>

C# 代码

protected void txtSuppName_TextChanged(object sender, EventArgs e)
        {
DataTable CustomRangePaymentDT = new DataTable();
CustomRangePaymentDT = SrcHldObj.BalSearchViewAccess("SELECT *FROM payment_view WHERE trimmed_date BETWEEN '" + (Convert.ToDateTime(txtFromDate.Text)).ToString("MM/dd/yyyy") + "' AND '" + (Convert.ToDateTime(txtToDate.Text)).ToString("MM/dd/yyyy") + "'");
                if (CustomRangePaymentDT.Rows.Count == 0)
                {
                    lblError.Text = "Sorry! No result found";
                    lblError.Visible = true;
                }
gvSuppPayment.DataSource = CustomRangePaymentDT;
                gvSuppPayment.DataBind();

        }

谢谢你的建议。。

4

1 回答 1

0

我可以理解的是,您需要为您的文本框提供自动建议功能。您需要在文本框的 keydown 事件中执行此操作。您可以进行 AJAX 调用以获取建议。

于 2013-09-04T10:52:19.690 回答