i am developing application in which i have a text box for writing supplier and shows the list of supplier match with the input text by calling text change method and shows the result in grid view but the problem is, that the method is invoked when i click outside the text box but i want it, to fire as soon as user types in the text box
ASP code
<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# Code
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();
}
Thanks in adv..
Upto to which I can understand is, you want an auto suggestion functionality for your textbox. You need to do this in the keydown event of the textbox. You can make an AJAX call to get the suggestion.