Click here to Skip to main content
15,850,214 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i am having a gridview binded with sqldatasource...i want to filter datasource with textbox text but with query as..
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        DeleteCommand="DELETE FROM EXP_TBL WHERE (ExpID = @ExpID)"
        SelectCommand="SELECT * FROM EXP_TBL"
        FilterExpression="Title = SELECT * FROM EXP_TBL WHERE ((ExpID LIKE '%@SearchName%') OR (ExpName LIKE '%@SearchName%') OR (ExpAmount LIKE '%@SearchName%') OR (ExpDate LIKE '%@SearchName%') OR (ExpDescription LIKE '%@SearchName%'))">
            <asp:Parameter Name="ExpenseID" />
            <asp:ControlParameter Name="Title" ControlID="TextBox2"

how to achieve this..................
it worked when filling gridview from codebehind.......
Since, i am having a formview binded to to reduce efforts i am using sqldatasource...

I don't think you need a Select Statement inside FilterExpression.

You should declare it like...
FilterExpression="Title LIKE '{0}%'"

Refer - Filter GridView with TextBox using FilterExpression in SqlDataSource in ASP.Net[^]
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