try this
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Label lblDate = e.Row.FindControl("Label27") as Label;
DateTime date; string yourDateFormat = "MM/dd/yyyy";
if (lblDate != null)
if (!string.IsNullOrEmpty(lblDate.Text))
if (DateTime.TryParseExact(lblDate.Text, yourDateFormat, CultureInfo.CurrentCulture, DateTimeStyles.None, out date))
{
bool show = date <= DateTime.Today.AddDays(45);
e.Row.Visible = show;
}
}
use
DateTime.TryParseExact Method [
^] to convert string to datetime.