If you are using ADO.NET with DataTable for binding your GridView, then you can do something like this:
protected void BindGrid(string searchText){
using(SqlConnection connection = new SqlConnection("YOUR CONNECTION STRING HERE")){
using(SqlCommand cmd = new SqlCommand(sql,connection)){
string sql = "SELECT * FROM TableName WHERE YourFieldName = @Param1";
cmd.Parameters.AddWithValue("@Param1", searchText);
DataTable dt = new DataTable();
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
if (dt.Rows.Count > 0) {
GridView1.DataSource = dt;
GridView1.DataBind();
}
else
{
}
}
}
}
protected void Button1_Click(object sender, EventArgs e){
BindGrid(YourTextBoxID.Text.Trim());
}
The code above is the typical way to search for a particular records in the database based on a TextBox value. You may need to validate the text to ensure validate dates format. You can also use a MaskEdit or Calendar extender control for your TextBox to ensure that the dates entered is valid. Depending on your datatype, you may also need to do a datatype conversion from string to datetime.
Hope that helps.