Gridview search using form or querystring parameter
Posted on 2008-10-23
I have a simple gridview on a page which is populated with a query that has a parameter in it. Here's the query.
SELECT db_key, email_address, company_name, date_entered, valid_email
WHERE (email_address LIKE '%' + @email + '%')
I have a text box called searchTextBox on the same web page as the gridview. There is also a regular button. I want the user to be able to enter a search string, click search and see the filtered results.
<asp:TextBox ID="searchTextBox" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Search" />
If I use the querystring parameter and type the url with a query parameter, it works fine. But if I use the form parameter it doesn't return any records.
<asp:FormParameter FormField="searchTextBox" Name="email" Type="string" />
I thought that postback was enabled by default. Am I missing something?