Q:

String TextBox1 text in a search parameter in SQL statement

I have the following Gridview which I am trying to pass a search parameter, to update the results based on that search -
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" />
<asp:Label ID="Label1" runat="server" Text="Grid not refreshed yet."></asp:Label><br />
<asp:Label ID="Label4" runat="server" Text="(Grid Will Referesh after Every Second)"Font-Bold="true"></asp:Label>     
<br /><br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:MyDbConn %>" 
         SelectCommand="SELECT * FROM [table] WHERE BODYTEXT LIKE='"+TextBox1.text+"></asp:SqlDataSource>  

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        BackColor="Black" DataSourceID="SqlDataSource1" Font-Names="Arial Black" 
        Font-Size="Small" ForeColor="White" Height="650px" Width="930px">
    </asp:GridView>
</ContentTemplate>

However I cant seem to get the SQL statement to accept the TextBox1 text that the user is entering, how can I resolve this?

A:

You must do this in code behind. 
SqlDataSource1.SelectCommand = "SELECT * FROM [table] WHERE BODYTEXT LIKE='"+TextBox1.Text;

You can do this when clicking on the search button.

