CustomersList.DataSource = dt;
Datatable dt; private void txt_usersearch_TextChanged(object sender, EventArgs e) { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["SalesInventoryManagement.Properties.Settings.Setting"].ConnectionString)) { using (var cmd = new SqlCommand("usp_GetCustomers", con)) { cmd.CommandType = CommandType.StoredProcedure; dt.DefaultView.RowFilter = "Full_Name LIKE '%{txt_usersearch.Text}%'"; CustomersList.DataSource = dt; } } } and this code is to display my data to datagridview public class Display { public static void Display_Customer(DataTable dt, DataGridView dgv) { using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["SalesInventoryManagement.Properties.Settings.Setting"].ConnectionString)) { using (var cmd = new SqlCommand("usp_GetCustomers", con)) { con.Open(); cmd.CommandType = CommandType.StoredProcedure; using (var sda = new SqlDataAdapter(cmd)) { dt = new DataTable(); sda.Fill(dt); dgv.DataSource = dt; } con.Close(); } } } } Form load private void ManageCustomer_Load(object sender, EventArgs e) { Display.Display_Customer(dt, CustomersList); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)