I am creating a website that needs to be able to search a database that contains information on fish. I wish to filter the grid view on both the "scientific name" of the fish and also its "common name". For this i have created two text boxes one named "txtScientificName" and one called "txtCommonName" each of which has a corresponding button. The code below is what i have so far and searches just the "Scientific Name" based on the criteria entered into the text box "txtScientificName" when the user presses enter.
I wish to be able to do the same for the common name but have the process attached to a button and for the user to be able to search using either the Scientific Name or Common Name. Any help with this would be very much appreciated.
Thanks in advance
Ryan
Code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" width="800px"
AutoGenerateColumns="False" DataSourceID="FishOverview"
HorizontalAlign="Center" BorderStyle="None" GridLines="Horizontal">
<Columns>
<asp:BoundField DataField="ScientificName" HeaderText="Scientific Name"
SortExpression="ScientificName" />
<asp:BoundField DataField="CommonName" HeaderText="Common Name"
SortExpression="CommonName" />
<asp:BoundField DataField="FishSpecies" HeaderText="Fish Species"
SortExpression="FishSpecies" />
</Columns>
<RowStyle HorizontalAlign="Center" />
</asp:GridView>
<asp:SqlDataSource ID="FishOverview" runat="server"
ConnectionString="<%$ ConnectionStrings:db_0905193_CO6009ConnectionString %>"
SelectCommand="SELECT FishPhoto, ScientificName, CommonName, FishSpecies FROM tblFish WHERE (ScientificName LIKE '%' + @ScientificName + '%') ">
<SelectParameters>
<asp:ControlParameter ControlID="txtScientificName" Name="ScientificName"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
I wish to be able to do the same for the common name but have the process attached to a button and for the user to be able to search using either the Scientific Name or Common Name. Any help with this would be very much appreciated.
Thanks in advance
Ryan