protected void btnSearch_Click(object sender, EventArgs e)
{
List<yourclassname> lstList = yourClassName.GetAllRecords();
var record = from rec in lstList where rec.uname == txtSearch.Text.Trim() select rec;
grvTest.DataSource = record;
grvTest.DataBind();
}
you can use this code in which "GetAllRecords()"is the static method defind in your class having name "yourClassName" which return you all record at a time and based on the value entered in your search textbox the records is being bind to your grid view dynamically.
you can fetch the record by using sql query also. but it is preffer to use linq.
[edit]code block fixed[/edit]