Hi niubee,
Check this example. Now please take its reference and correct your code.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
HTML
<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true" DataSourceID="SqlDataSource2" DataTextField="Country" DataValueField="Country">
<asp:ListItem Text="Please select" Value="" />
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT [Country] FROM [Customers]"></asp:SqlDataSource>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" />
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">
<AlternatingItemTemplate>
<td runat="server" style="">CustomerID:
<asp:Label runat="server" Text='<%# Eval("CustomerID") %>' />
<br />
ContactName:
<asp:Label runat="server" Text='<%# Eval("ContactName") %>' />
<br />
City:
<asp:Label runat="server" Text='<%# Eval("City") %>' />
<br />
Country:
<asp:Label runat="server" Text='<%# Eval("Country") %>' />
<hr />
</td>
</AlternatingItemTemplate>
<EditItemTemplate>
<td runat="server" style="">CustomerID:
<asp:Label runat="server" Text='<%# Eval("CustomerID") %>' />
<br />
ContactName:
<asp:TextBox runat="server" Text='<%# Eval("ContactName") %>' />
<br />
City:
<asp:TextBox runat="server" Text='<%# Eval("City") %>' />
<br />
Country:
<asp:TextBox runat="server" Text='<%# Eval("Country") %>' />
<hr />
</td>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<EmptyItemTemplate>
<td runat="server" />
</EmptyItemTemplate>
<GroupTemplate>
<tr id="itemPlaceholderContainer" runat="server">
<td id="itemPlaceholder" runat="server"></td>
</tr>
</GroupTemplate>
<InsertItemTemplate>
<td runat="server" style="">CustomerID:
<asp:Label runat="server" Text='<%# Eval("CustomerID") %>' />
<br />
ContactName:
<asp:TextBox runat="server" Text='<%# Eval("ContactName") %>' />
<br />
City:
<asp:TextBox runat="server" Text='<%# Eval("City") %>' />
<br />
Country:
<asp:TextBox runat="server" Text='<%# Eval("Country") %>' />
<hr />
</td>
</InsertItemTemplate>
<ItemTemplate>
<td runat="server" style="">CustomerID:
<asp:Label runat="server" Text='<%# Eval("CustomerID") %>' />
<br />
ContactName:
<asp:Label runat="server" Text='<%# Eval("ContactName") %>' />
<br />
City:
<asp:Label runat="server" Text='<%# Eval("City") %>' />
<br />
Country:
<asp:Label runat="server" Text='<%# Eval("Country") %>' />
<hr />
</td>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="groupPlaceholderContainer" runat="server" border="0" style="">
<tr id="groupPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
<asp:DataPager ID="DataPager1" runat="server" PageSize="12">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<td runat="server" style="">CustomerID:
<asp:Label runat="server" Text='<%# Eval("CustomerID") %>' />
<br />
ContactName:
<asp:Label runat="server" Text='<%# Eval("ContactName") %>' />
<br />
City:
<asp:Label runat="server" Text='<%# Eval("City") %>' />
<br />
Country:
<asp:Label runat="server" Text='<%# Eval("Country") %>' />
<hr />
</td>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [CustomerID], [ContactName], [City], [Country] FROM [Customers] WHERE ([ContactName] LIKE '%' + @ContactName + '%') AND (Country = @Country OR ISNULL(@Country,'') = '')">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="ContactName" PropertyName="Text" Type="String" ConvertEmptyStringToNull="false" />
<asp:ControlParameter ControlID="DropDownList1" Name="Country" PropertyName="SelectedValue" Type="String" ConvertEmptyStringToNull="false" />
</SelectParameters>
</asp:SqlDataSource>
Screenshot
![](https://i.imgur.com/fga0JLB.gif)