TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
shashi reddy
NA
186
155.1k
textbox and button
Mar 29 2011 4:18 AM
hai 2 all
I have an option of search on my web page
<asp:TextBox ID="txtSearch" runat="server" AutoPostBack="True"
ontextchanged="txtSearch_TextChanged"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" onclick="btnSearch_Click" />
---------------------------------------------------------------------
code
---------------------------------------------------------------------
protected void txtSearch_TextChanged(object sender, EventArgs e)
{
this.txtsearching();
}
protected void btnSearch_Click(object sender, EventArgs e)
{
this.txtsearching();
}
private void txtsearching()
{
string strSQL = "";
if (txtSearch.Text.Trim() == "")
{
strSQL = "select * from customers where flag=1 ORDER BY customer_code";
}
else
{
strSQL = "select * from customers where flag=1 and (customer_code like '%" + txtSearch.Text.Trim() + "%' or customer_organization_name like '%" + txtSearch.Text.Trim() + "%')";
}
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["constring"].ToString());
SqlDataAdapter sda = new SqlDataAdapter(strSQL, con);
DataTable dt = new DataTable();
sda.Fill(dt);
gvKenyacustomers.DataSource = dt;
gvKenyacustomers.DataBind();
sda.Dispose();
con.Dispose();
dt.Dispose();
txtSearch.Text = "";
}
-------------------------------------------------------------------
1)my problem is when ever i am entering sme text in textbox txtSearch_TextChanged is fireing..twice
2) after entering the text in textbox and onclicking the search button btnSearch_Click is not fireing. txtSearch_TextChanged is fireing again
what is the solution for this...
when entering the text in textbox and hit the enter then txtSearch_TextChanged has to fire only once
and when we enter the text in textbox and if hit the search button...
btnSearch_Click has to fire..
Reply
Answers (
3
)
About set up connection string
Regular expression to Test for Positive Number both Integer & Real