Click here to Skip to main content
15,945,119 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i tried this code for solve that problem but it not working properly then give a right searching solution.
C#
string s = Request.QueryString["serc"];
    SqlDataAdapter ad = new SqlDataAdapter("SELECT product_tbl.pname, product_tbl.path, product_tbl.price, product_tbl.cat, product_detail.product_info FROM product_tbl INNER JOIN product_detail ON product_tbl.pro_id = product_detail.pro_id  where product_tbl.pname like '%" + s + "%'", con);

    DataSet ds = new DataSet();
    con.Open();
    ad.Fill(ds);
    con.Close();
    GridView1.DataSource = ds;
    GridView1.DataBind();
Posted
Updated 19-Sep-13 19:54pm
v2
Comments
[no name] 20-Sep-13 1:38am    
What do you mean by not working properly..??and what more you are expecting..??
sinsinwar rahul 20-Sep-13 2:01am    
i mean that code pick up whole records from db .......whatever typing in textbox i only wants selected records whatever i typed in textbox.
CodeBlack 20-Sep-13 1:55am    
what error you are getting ?
sinsinwar rahul 20-Sep-13 2:02am    
i mean that code pick up whole records from db .......whatever typing in textbox i only wants selected records whatever i typed in textbox.
CodeBlack 20-Sep-13 2:10am    
do you get values what you have typed in Request.QueryString["serc"] ?

1 solution

First you need to check whether you are getting correct value in Request.QueryString["serc"].
Second, as you are using '%<searchstring>%', it would retrieve all the items which contain 'searchString' in the Product names.
For example, if all of the products contain 'pro'(anywhere in the product names) & your searchString is also 'pro', it'll return all the items.
 
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