Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello sir,
i have 2 textbox and one button for Search.....
in my database alrady have record but i want to when i fill search in textbox and click button on searchButton then my all releted data will show in gridView......
please help...
Posted
Comments
OriginalGriff 10-Dec-13 10:00am    
And what do you need help with?
What have you tried?
Where are you stuck?
Rajnish D mishra 10-Dec-13 10:06am    
sorry i disturb u ....i tried my self and i due this.... i am college stud..so i not have more well develop knowledge.

You could try this..

C#
protected void btnSearch_Click(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection("YourConnection");
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = conn;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "sp_Search";
        cmd.Parameters.AddWithValue("@TEXTBOX1", TextBox1.Text);
        cmd.Parameters.AddWithValue("@TEXTBOX2", TextBox2.Text);
        cmd.ExecuteNonQuery();
        DataTable dt = new DataTable();
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        da.Fill(dt);
        gvYourGrid.DataSource = dt;
        gvYourGrid.DataBind();
    }


And then create a stored procedure like this in your SQL

SQL
CREATE PROCEDURE [dbo].[sp_Search]
	@TEXTBOX1 AS VARCHAR(100),
	@TEXTBOX2 AS VARCHAR(100)
AS
BEGIN
	SELECT * FROM YourTable WHERE YourColumn1 = @TEXTBOX1 and YourColumn2 = @TEXTBOX2
END
 
Share this answer
 
Have a read of this Using ADO.NET for beginners[^]
 
Share this answer
 
U need to handle the click Event of button and and write method with database query...


Hope, this will help you..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900