Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am using this code for filtering datagridview, it's filtering but blank row display of this search character.
C#
var dataTable = (DataTable)dgvDisplayTiles.DataSource;
                var dataView = dataTable.DefaultView;
                dataView.RowFilter = string.Format("FloorTileName like '{0}%'", txtSearchByName.Text);


please help me, How can we display filling datagridview row according to search character.

Thanks in Advance.

Ankit Agarwal
Software Engineer
Posted

write dgvDisplayTiles.DataBind() after the setting the rowfilter.
 
Share this answer
 
Comments
[no name] 11-Dec-13 6:40am    
It's windows application, dgvDisplayTiles.DataBind() it's not working.
Hi


your filter is fine..

after filtering, assign the DataView to the grid not the Datatable.
C#
dgvDisplayTiles.DataSource =  dataView;


Its safe to Trim the value from text box for any unwanted empty spaces.

C#
txtSearchByName.Text.Trim();
 
Share this answer
 
Comments
[no name] 11-Dec-13 7:23am    
blank row displayed.
Karthik_Mahalingam 11-Dec-13 7:52am    
can u post some values of FloorTileName and also the txtSearchByName value...
Gaurav Makwana 17-Dec-13 3:49am    
good karthik
Karthik_Mahalingam 17-Dec-13 4:08am    
thanks gaurav :-)

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