Try like Below it will help you....
In HTML Design View, Before the DataGridView add the Below code, It will create the Textbox and Button
HTML:
Enter the Name of the file : <asp:TextBox ID="txtFilter" runat="server"></asp:TextBox>
<asp:Button ID="btnShow"
runat="server" Text="ShowData" onclick="btnShow_Click" />
Add Button Click event like below...
CS:
protected void btnShow_Click(object sender, EventArgs e)
{
ShowData();
}
public void ShowData()
{
string FilterValue = txtFilter.Text.ToUpper();
DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath(""));
FileInfo[] info = dirInfo.GetFiles("*.zip"); //Get FileInfo and Save it a FileInfo[] Array
List<Getfiles> _items = new List<Getfiles>(); // Define a List with Two coloums
foreach (FileInfo file in info) //Loop the FileInfo[] Array
_items.Add(new Getfiles { Name = file.Name, LastWriteTime = file.LastWriteTime.ToString("MM/dd/yyyy") }); // Save the Name and LastwriteTime to List
//you can use Any one the Filtered list from the below...
var tlistFiltered = _items.Where(item => item.Name.ToUpper() == FilterValue); // Find the File by their File Name
var tlistFiltered1 = _items.Where(item => item.Name.ToUpper().Contains(FilterValue)); // Find the file that Contains Specific word in its File Name
var tlistFiltered2 = _items.Where(item => item.Name.ToUpper().StartsWith(FilterValue));// Find tha File that StartsWith Some Specific Word
articleList.DataSource = tlistFiltered; //Assign the DataSource to DataGrid
articleList.DataBind();
}
public class Getfiles
{
public string Name { get; set; }
public string LastWriteTime { get; set; }
}
OutPut Screen :