我正在开发应用程序,其中我有一个用于编写供应商的文本框,并通过调用文本更改方法显示供应商与输入文本匹配的列表,并在网格视图中显示结果但问题是,该方法被调用当我在文本框外面点击但我想要它时,只要用户在文本框中输入
就会立即触发ASP代码
<table style="width: 100%;">
<tr>
<td style="font-weight: bold; font-size: medium; text-align: right;">
Supplier Name
</td>
<td style="text-align: left">
<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();
}
先谢谢。
答案 0 :(得分:0)
我能理解的是,您需要为文本框提供自动建议功能。您需要在文本框的keydown事件中执行此操作。您可以进行AJAX调用以获取建议。