Hello,
I would like make this search code to SqlDataSource
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:cmConnectionString %>" SelectCommand="SELECT * FROM [Cities]"></asp:SqlDataSource>
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["cmConnectionString"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText =
"Select* from Table_infoname where name LIKE '%' + @SearchText + '%' OR civilid LIKE '%' + @SearchText + '%'";
cmd.Parameters.AddWithValue("@SearchText", prefixText);
cmd.Connection = conn;
conn.Open();
List<string> customers = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
customers.Add(sdr["name"].ToString());
}
}
conn.Close();
return customers;
}
}