Hi
I have created a sample which full fill your requirement you need to modify the code according to your need.
HTML
<div>
<br />
Country:-
<asp:TextBox ID="txtCountry" runat="server" TextMode="MultiLine" Rows="10"></asp:TextBox>
<br />
<asp:Button ID="btnSearch" Text="Search" OnClick="Search" runat="server" />
<br />
<br />
<asp:GridView ID="gvCustomers" runat="server" />
</div>
C#
protected void Search(object sender, EventArgs e)
{
string constring = ConfigurationManager.ConnectionStrings["constr"].ToString();
string countryName = txtCountry.Text.Replace(Environment.NewLine, "#");
string[] countryNames = countryName.Split('#');
string query = "SELECT CustomerID,CompanyName,ContactName,Country FROM Customers ";
string whereCondition = "WHERE ";
foreach (string name in countryNames)
{
whereCondition += "Country LIKE '%" + name + "%' OR ";
}
query += whereCondition.Substring(0, whereCondition.LastIndexOf("OR"));
using (SqlConnection con = new SqlConnection(constring))
{
using (SqlCommand cmd = new SqlCommand(query, con))
{
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(dt);
gvCustomers.DataSource = dt;
gvCustomers.DataBind();
}
}
}
VB.Net
Protected Sub Search(sender As Object, e As EventArgs)
Dim constring As String = ConfigurationManager.ConnectionStrings("constr").ToString()
Dim countryName As String = txtCountry.Text.Replace(Environment.NewLine, "#")
Dim countryNames As String() = countryName.Split("#"C)
Dim query As String = "SELECT CustomerID,CompanyName,ContactName,Country FROM Customers "
Dim whereCondition As String = "WHERE "
For Each name As String In countryNames
whereCondition += (Convert.ToString("Country LIKE '%") & name) + "%' OR "
Next
query += whereCondition.Substring(0, whereCondition.LastIndexOf("OR"))
Using con As New SqlConnection(constring)
Using cmd As New SqlCommand(query, con)
Dim dt As New DataTable()
Dim sda As New SqlDataAdapter(cmd)
sda.Fill(dt)
gvCustomers.DataSource = dt
gvCustomers.DataBind()
End Using
End Using
End Sub
ScreenShot