I have a gridview which shows all the information of the data table. I have a textbox and a button. If I want to search some particular files in the gridview, I need to enter the filename in textbox and hit search button. I’m taking care of this with the code
// don't copy and paste this; it is vulnerable to sql injection attacks
SqlDataSource1.SelectCommand =
"select * from Table1 where FileName like '%" + TextBox1.Text + "%'" ;
SqlDataSource1.DataBind();
I want to display the message like “file not found” if there are no search results. How can I do that?
You could use the emptydatatext property. http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.emptydatatext(v=VS.90).aspx