Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to filter rows from datagridview using this line of code in textChanged event of the textbox but
C#
(gvSideMember.DataSource as DataTable).DefaultView.RowFilter = string.Format("F_NAME LIKE '%{0}%'", textSearch.Text);

it shows me this error
Object refrence is not set to an instance? how do I solve it.
Posted
Comments
Thomas ktg 5-Dec-13 1:31am    
Check the DataSource has value in it. If then check the column name is same for RowFilter and DataSource.
mschotamaster 5-Dec-13 1:43am    
Datasource is not null how during debuging datatable is null

1 solution

Try this code
C#
DataView dv = ((DataTable)dataGridView1.DataSource).DefaultView;
  dv.RowFilter = "FromColumn like '%" + textBox1.Text + "%'";
  dataGridView1.DataSource = dv;

thanks & Regard
Sham :)
 
Share this answer
 
Comments
mschotamaster 5-Dec-13 1:15am    
Its give me same error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900