This is our Very first C# Lesson. In this lesson, Today We going to discuss how to search data from datatable using a textbox and display it into datagridview in C#?. before doing this you need setup all thing ! Like adding data and deleting data, updating data Etc. this is a common Methord !!
1) Select Your TextBox And goto the Event Section in the Property Window
2) Dubble Click the TextChanged Row
3 ) Copy the Below Code to your Project
private void textBox11_TextChanged_1(object sender, EventArgs e)
{
(dataGridView1.DataSource as DataTable).DefaultView.RowFilter = string.Format("PurchaseID LIKE '%{0}%'", textBox11.Text);
}
4) Then Change Clour Ares
- Your datagridview Name dataGridView1
- Your Database Column Name PurchaseID
- Your Textbox Name Textbox11
5) Now Click Save Button
Post a Comment