Last post Jun 27, 2012 06:39 AM by ghostman126
Jun 27, 2012 02:13 AM|ghostman126|LINK
I am trying to implement a simple search function but it is not working programitically.
In my sqldatasource1 in the aspx file, I have the select statement: SELECT Name, Location, ImageUrl FROM Listings WHERE (@SearchKey LIKE '%' + @SearchString + '%') AND (CatID = @CatID)
The problem is with the @SearchKey. When I manually type the SearchKey it works but when I add it from behind code,
SqlDataSource1.SelectParameters["SearchKey"].DefaultValue = searchkey;
it doesn't work.
Can someone help? Thanks
Jun 27, 2012 02:24 AM|mezzanine74|LINK
Delete SearchKey parameter and define your SelectCommand on code behind. I think this will work, please give a try.
Delete This line of code
Use This line of code
SqlDataSource1.SelectCommand= "SELECT Name, Location, ImageUrl FROM Listings WHERE (" + SearchKey + " LIKE '%' + @SearchString + '%') AND (CatID = @CatID) "
Jun 27, 2012 06:39 AM|ghostman126|LINK
Thank you! That helped!