6
Answers

How to compare Date values in DataGrid with Current date?

Dawood Abbas

Dawood Abbas

9y
631
1
I have tried with
protected void gridCustomer_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DateTime olddate = Convert.ToDateTime(e.Row.Cells[9].Text);  /*Error : String was not recognized as a valid DateTime.*/
DateTime today = DateTime.Now;
if (olddate > today)
                {
                    Label status = (Label) e.Row.FindControl("lblStatus");
                    status.Text = "AutoHold";
                }    
}

Answers (6)