There is a table. And it is filled with data:
SELECT IncomeLetters.Income_ID, IncomeLetters.Income_Number, IncomeLetters.IncomeDate, IncomeLetters.SentAuthority, IncomeLetters.SentNum, IncomeLetters.SentNumDate, IncomeLetters.ContentLetter, IncomeLetters.IncomeAnswerTo, IncomeLetters.Deadline, IncomeLetters.Comment, IncomeLetters.imagepath, Employee.Surname, Resolution.Resolution, docState.docState, DocType.DocumentType, InDocType.InDocType, Theme.Theme FROM ....
It is necessary to select a row in the table when the following condition is fulfilled: Deadline = IncomeLettersDeadline
(column index "8") - did I calculate correctly? (started account "0")
DeadLine < Today's date
C # Code:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var tdday = DateTime.Now; var deadline = Convert.ToDateTime(e.Row.Cells[9].Text); if (tdday > deadline) { //Setting row back colour e.Row.BackColor = Color.Red; } } }
In the end I get
ERROR: The string was not recognized as a valid DateTime value due to an incorrect day of the week value.
{ var tdday = DateTime.Now; var deadline = Convert.ToDateTime(e.Row.Cells[8].Text); if (tdday > deadline) { ... } ... }
Stack trace:
[FormatException: Строка не распознана как действительное значение DateTime из-за некорректного значения дня недели.] System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +11626318 System.Convert.ToDateTime(String value) +83 PreviewIncomeletter.GridView1_RowDataBound(Object sender, GridViewRowEventArgs e) in c:\Users\Somon\Desktop\NAIK-XC\PreviewIncomeletter.aspx.cs:45 System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e) +111 System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +181 System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +3660 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +67 System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128 System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +34 System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143 System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74 System.Web.UI.WebControls.GridView.DataBind() +9 System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +114 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +75 System.Web.UI.Control.EnsureChildControls() +92 System.Web.UI.Control.PreRenderRecursiveInternal() +42 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Control.PreRenderRecursiveInternal() +160 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4775
Please help.