Reputation: 8682
i have few text boxes and dropdown boxes in a search window,and when click search button it will display data on gridview based on value selection in controls.Now what i want is even without clicking on search button it will display data automatically in gridview based on control selection.How to achieve it.I am posting small snippet contains only text box.
<div>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
</div>
<div>
<asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />
</div>
<div>
<asp:GridView ID="grdresults" runat="server"></asp:GridView>
</div>
protected void Button1_Click(object sender, EventArgs e)
{
try
{
LoadData();
BindGrid();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
The above LoadData(); method will create the search criteria (where
clause for oracle query) and will get data in to datatable
which will be in session
,Then BindGrid(); will assign data to grdresult
gridview.Search is working fine by clicking the button,but i want it in an automated way
Upvotes: 0
Views: 2024
Reputation: 495
<asp:TextBox ID="txtFirstName" runat="server" TextChanged="txtFirstName_TextChanged"></asp:TextBox>
protected void txtFirstName_TextChanged(object sender, EventArgs e)
{
try
{
LoadData();
BindGrid();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
Upvotes: 1