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

i'm a newbie. i would like to inquire if is it possible to filter datagridview with all the records containing some word? for example in the textbox, i will search for the name mark. the datagridview will show all the records with a name containing mark such as mark anthony, mark brian, marky, markus, etc.

br,

parvenu1
Posted

change the datasource on the fly - in the code behind.

say for example
in page load you have
sql.commandtext = "select * from users"; 
gridview1.datasource = sql.ExecuteReader();


in search button click:
sql.commandtext = "select * from users where name LIKE '%" + textbox1.text + "%'";
gridview1.datasource = sql.ExecuteReader(); 



GL
 
Share this answer
 
yes this is possible on button click event u have to write

Sqlcommand cmd=new Sqlcommand ("select * from tablename where name like '%"+TextBox1.Text+"%'",con);
con.open();
SqldataReader dtr=cmd.executeReader();
GridView1.DataSource=dtr;
GridView1.DataBind();
con.Close();
 
Share this answer
 
i would like to inquire if is it possible to filter datagridview with all the records containing some word
Yes! Possible...

Start looking from here: DataGrid Filter[^]
Google for more, if needed.
 
Share this answer
 
Specify the filter condition to data object containing data before binding data to GridView.
 
Share this answer
 

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